Class: String
Instance Method Summary collapse
- #capitalize_first_letter ⇒ Object
-
#coerce(a) ⇒ Object
nodoc#.
- #from_orient ⇒ Object (also: #expand)
- #quote ⇒ Object
-
#rid ⇒ Object
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
- #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
128 129 130 |
# File 'lib/other.rb', line 128 def capitalize_first_letter self.sub(/^(.)/) { $1.capitalize } end |
#from_orient ⇒ Object Also known as: expand
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/other.rb', line 146 def from_orient if rid? ActiveOrient::Model.autoload_object self elsif self =~ /^:.*:$/ self[1..-2].to_sym else self end end |
#quote ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/other.rb', line 189 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 (format: “nn:mm”) or nil
169 170 171 |
# File 'lib/other.rb', line 169 def rid self["#"].nil? ? self : self[1..-1] if rid? end |
#rid? ⇒ Boolean
a rid is either #nn:nn or nn:nn
164 165 166 |
# File 'lib/other.rb', line 164 def rid? self =~ /\A[#]{,1}[0-9]{1,}:[0-9]{1,}\z/ end |
#to_a ⇒ Object
185 186 187 |
# File 'lib/other.rb', line 185 def to_a [ self ] end |
#to_classname ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/other.rb', line 173 def to_classname if self[0] == '$' self[1..-1] else self end end |
#to_human ⇒ Object
207 208 209 |
# File 'lib/other.rb', line 207 def to_human self end |
#to_or ⇒ Object
181 182 183 |
# File 'lib/other.rb', line 181 def to_or quote end |
#to_orient ⇒ Object
if the string contains “#xx:yy” omit quotes
159 160 161 |
# File 'lib/other.rb', line 159 def to_orient rid? ? "#"+rid : self # return the string (not the quoted string. this is to_or) end |
#where(**args) ⇒ Object
end
140 141 142 143 144 |
# File 'lib/other.rb', line 140 def where **args if rid? from_orient.where **args end end |