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_classname ⇒ Object
- #to_or ⇒ Object
-
#to_orient ⇒ Object
String#ToOrient: if the string contains “#xx:yy” omit quotes.
Instance Method Details
#capitalize_first_letter ⇒ Object
185 186 187 |
# File 'lib/other.rb', line 185 def capitalize_first_letter self.sub(/^(.)/) { $1.capitalize } end |
#from_orient ⇒ Object
189 190 191 192 193 194 195 196 197 198 |
# File 'lib/other.rb', line 189 def from_orient if rid? ActiveOrient::Model.autoload_object self elsif self =~ /^:.*:$/ self[1..-2].to_sym else self end end |
#quote ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/other.rb', line 238 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
221 222 223 |
# File 'lib/other.rb', line 221 def rid rid? ? self : nil end |
#rid? ⇒ Boolean
a rid is either #nn:nn and nn:nn
216 217 218 |
# File 'lib/other.rb', line 216 def rid? self =~ /\A[#]{,1}[0-9]{1,}:[0-9]{1,}\z/ end |
#to_classname ⇒ Object
225 226 227 228 229 230 231 |
# File 'lib/other.rb', line 225 def to_classname if self[0] == '$' self[1..-1] else self end end |
#to_or ⇒ Object
233 234 235 |
# File 'lib/other.rb', line 233 def to_or quote end |
#to_orient ⇒ Object
String#ToOrient: if the string contains “#xx:yy” omit quotes
201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/other.rb', line 201 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 |