class String
Public Instance Methods
capitalize_first_letter()
click to toggle source
# File lib/other.rb, line 179 def capitalize_first_letter self.sub(/^(.)/) { $1.capitalize } end
from_orient()
click to toggle source
from orient translates the database response into active-orient objects
symbols are representated via “:{something]:}”
database records respond to the “rid”-method
other values are not modified
# File lib/other.rb, line 204 def from_orient if rid? ActiveOrient::Model.autoload_object self elsif self =~ /^:.*:$/ # symbol-representation in the database self[1..-2].to_sym else self end end
Also aliased as: expand
quote()
click to toggle source
# File lib/other.rb, line 248 def quote str = self.dup if str[0, 1] == "'" && str[-1, 1] == "'" self else last_pos = 0 while (pos = str.index("'", last_pos)) str.insert(pos, "\\") if pos > 0 && str[pos - 1, 1] != "\\" last_pos = pos + 1 end "'#{str}'" end end
rid()
click to toggle source
return a valid rid (format: “nn:mm”) or nil
# File lib/other.rb, line 227 def rid self["#"].nil? ? self : self[1..-1] if rid? end
Also aliased as: rrid
rid?()
click to toggle source
a rid is either nn:nn or nn:nn
# File lib/other.rb, line 222 def rid? self =~ /\A[#]{,1}[0-9]{1,}:[0-9]{1,}\z/ end
to_a()
click to toggle source
# File lib/other.rb, line 244 def to_a [ self ] end
to_classname()
click to toggle source
# File lib/other.rb, line 232 def to_classname if self[0] == '$' self[1..-1] else self end end
to_human()
click to toggle source
def coerce a nodoc#
nil
end
# File lib/other.rb, line 266 def to_human self end
to_or()
click to toggle source
# File lib/other.rb, line 240 def to_or quote end
to_orient()
click to toggle source
if the string contains “#xx:yy” omit quotes
# File lib/other.rb, line 217 def to_orient rid? ? "#"+rid : self # return the string (not the quoted string. this is to_or) end
where(**args)
click to toggle source
as_json has unexpected side-effects, needs further consideration
def as_json o=nil
if rid? rid else super o end
end
# File lib/other.rb, line 191 def where **args if rid? from_orient.where **args end end