Class: String
Instance Method Summary collapse
- #capitalize_first_letter ⇒ Object
-
#from_orient ⇒ Object
(also: #expand)
from orient translates the database response into active-orient objects.
- #quote ⇒ Object
-
#rid ⇒ Object
(also: #rrid)
return a valid rid (format: “nn:mm”) or nil.
-
#rid? ⇒ Boolean
a rid is either #nn:nn or nn:nn.
- #to_a ⇒ Object
- #to_classname ⇒ Object
-
#to_human ⇒ Object
def coerce a #nodoc# nil end.
- #to_or ⇒ Object
-
#to_orient ⇒ Object
if the string contains “#xx:yy” omit quotes.
-
#where(**args) ⇒ Object
end.
Instance Method Details
#capitalize_first_letter ⇒ Object
179 180 181 |
# File 'lib/other.rb', line 179 def capitalize_first_letter self.sub(/^(.)/) { $1.capitalize } end |
#from_orient ⇒ Object Also known as: expand
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
204 205 206 207 208 209 210 211 212 213 |
# 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 |
#quote ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 260 |
# 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 ⇒ Object Also known as: rrid
return a valid rid (format: “nn:mm”) or nil
227 228 229 |
# File 'lib/other.rb', line 227 def rid self["#"].nil? ? self : self[1..-1] if rid? end |
#rid? ⇒ Boolean
a rid is either #nn:nn or nn:nn
222 223 224 |
# File 'lib/other.rb', line 222 def rid? self =~ /\A[#]{,1}[0-9]{1,}:[0-9]{1,}\z/ end |
#to_a ⇒ Object
244 245 246 |
# File 'lib/other.rb', line 244 def to_a [ self ] end |
#to_classname ⇒ Object
232 233 234 235 236 237 238 |
# File 'lib/other.rb', line 232 def to_classname if self[0] == '$' self[1..-1] else self end end |
#to_human ⇒ Object
def coerce a #nodoc#
nil
end
266 267 268 |
# File 'lib/other.rb', line 266 def to_human self end |
#to_or ⇒ Object
240 241 242 |
# File 'lib/other.rb', line 240 def to_or quote end |
#to_orient ⇒ Object
if the string contains “#xx:yy” omit quotes
217 218 219 |
# 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) ⇒ Object
end
191 192 193 194 195 |
# File 'lib/other.rb', line 191 def where **args if rid? from_orient.where **args end end |