Class: Array

Inherits:
Object show all
Defined in:
lib/other.rb

Direct Known Subclasses

OrientSupport::Array

Constant Summary collapse

@@accepted_methods =
[]

Instance Method Summary collapse

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

#analyseObject

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_orientObject



30
31
32
# File 'lib/other.rb', line 30

def from_orient
  map &:from_orient
end

#orient_flattenObject



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_humanObject



34
35
36
# File 'lib/other.rb', line 34

def to_human
	map &:to_human
end

#to_orObject



26
27
28
# File 'lib/other.rb', line 26

def to_or
  "["+ map( &:to_or).join(', ')+"]"
end

#to_orientObject

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