Class: Array
Direct Known Subclasses
Constant Summary collapse
- @@accepted_methods =
[]
Instance Method Summary collapse
-
#analyse ⇒ Object
used to enable def abc *key where key is a Range, an comma separated List or an item aimed to support #compose_where.
- #from_orient ⇒ Object
-
#method_missing(method, *args, &b) ⇒ Object
dummy for refining.
- #orient_flatten ⇒ Object
- #to_human ⇒ Object
- #to_or ⇒ Object
-
#to_orient ⇒ Object
Class extentions to manage to_orient and from_orient.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &b) ⇒ Object
dummy for refining
7 8 9 10 11 12 13 14 |
# File 'lib/other.rb', line 7 def method_missing method, *args, &b return if [:to_hash, :to_str].include? method if @@accepted_methods.include? method self.map{|x| x.public_send(method, *args, &b)} else raise ArgumentError.new("Method #{method} does not exist") end end |
Instance Method Details
#analyse ⇒ Object
used to enable def abc *key where key is a Range, an comma separated List or an item aimed to support #compose_where
42 43 44 45 46 47 48 49 50 |
# File 'lib/other.rb', line 42 def analyse # :nodoc: if first.is_a?(Range) first elsif size ==1 first else self end end |
#from_orient ⇒ Object
30 31 32 |
# File 'lib/other.rb', line 30 def from_orient map &:from_orient end |
#orient_flatten ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/other.rb', line 52 def orient_flatten while( first.is_a?(Array) ) self.flatten!(1) end self.compact! self ## return object end |
#to_human ⇒ Object
34 35 36 |
# File 'lib/other.rb', line 34 def to_human map &:to_human end |
#to_or ⇒ Object
26 27 28 |
# File 'lib/other.rb', line 26 def to_or "["+ map( &:to_or).join(', ')+"]" end |
#to_orient ⇒ Object
Class extentions to manage to_orient and from_orient
18 19 20 21 22 23 24 |
# File 'lib/other.rb', line 18 def to_orient if all?{ |x| x.respond_to?(:rid?)} && any?( &:rid? ) "["+ map{|x| x.rid? ? x.rid : x.to_or }.join(', ') + ']' else map(&:to_orient) # .join(',') end end |