Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/other.rb
Instance Method Summary collapse
- #capitalize_first_letter ⇒ Object
- #from_orient ⇒ Object
- #quote ⇒ Object
-
#rid ⇒ Object
return a valid rid or nil.
-
#rid? ⇒ Boolean
a rid is either #nn:nn and nn:nn.
- #to_a ⇒ Object
- #to_classname ⇒ Object
- #to_or ⇒ Object
-
#to_orient ⇒ Object
String#ToOrient: if the string contains “#xx:yy” omit quotes.
- #where(**args) ⇒ Object
Instance Method Details
#capitalize_first_letter ⇒ Object
226 227 228 |
# File 'lib/other.rb', line 226 def capitalize_first_letter self.sub(/^(.)/) { $1.capitalize } end |
#from_orient ⇒ Object
236 237 238 239 240 241 242 243 244 245 |
# File 'lib/other.rb', line 236 def from_orient if rid? ActiveOrient::Model.autoload_object self elsif self =~ /^:.*:$/ self[1..-2].to_sym else self end end |
#quote ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/other.rb', line 288 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
return a valid rid or nil
268 269 270 |
# File 'lib/other.rb', line 268 def rid rid? ? self : nil end |
#rid? ⇒ Boolean
a rid is either #nn:nn and nn:nn
263 264 265 |
# File 'lib/other.rb', line 263 def rid? self =~ /\A[#]{,1}[0-9]{1,}:[0-9]{1,}\z/ end |
#to_a ⇒ Object
284 285 286 |
# File 'lib/other.rb', line 284 def to_a [ self ] end |
#to_classname ⇒ Object
272 273 274 275 276 277 278 |
# File 'lib/other.rb', line 272 def to_classname if self[0] == '$' self[1..-1] else self end end |
#to_or ⇒ Object
280 281 282 |
# File 'lib/other.rb', line 280 def to_or quote end |
#to_orient ⇒ Object
String#ToOrient: if the string contains “#xx:yy” omit quotes
248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/other.rb', line 248 def to_orient if rid? if self[0] == "#" self else "#"+self end else self # return the sting (not the quoted string. this is to_or) end #self.gsub /%/, '(percent)' # quote end |
#where(**args) ⇒ Object
230 231 232 233 234 |
# File 'lib/other.rb', line 230 def where **args if rid? from_orient.where **args end end |