Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Should Property override to_s to return the value as a string? #3

Open
jamsden opened this Issue · 0 comments

1 participant

@jamsden

eyal.age now returns a Property, not a value as it did in the old API. You need to use eyal.age.first, or eyal.age.only to get the value. And this will fail if eyal.age is nil.

Should Property override to_s so that eyal.age prints the value of the property instead of its URI? This might be a convenience in string expressions and would provide some backward compatibility with the old API and examples.

The key is that all properties can be multi-valued. It seems that eyal.age should never return nil, it should return at least []. But currently it is possible that a property that has no value will be nil. In the context of multi-valued properties, is there a semantic difference between nil and []. The difference could be whether these is a schema defining the domain of the property or not.

def to_s
values = to_a
if values == nil then
""
elsif values.size == 1 then
"#{values[0]}"
else
"[#{values.collect{|obj| obj.inspect}.join(", ")}]"
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.