Module: Lims::Core::Base::IsArrayOf
- Defined in:
- lib/lims-core/base.rb
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Add content to compare If classe are not in the same hierarchy we only compare the content.
-
#[](i) ⇒ Object
Delegate [] to the underlying array.
- #[]=(i, value) ⇒ Object
-
#content ⇒ Array
The underlying array.
-
#each_content {|content| ... } ⇒ Object
iterate only between non empty lanes.
- #initialize(*args, &block) ⇒ Object
Instance Method Details
#==(other) ⇒ Boolean
Add content to compare If classe are not in the same hierarchy we only compare the content
78 79 80 81 82 83 84 |
# File 'lib/lims-core/base.rb', line 78 def ==(other) if other.is_a?(self.class) || self.is_a?(other.class) super(other) else !other.nil? end && self.to_a == other.to_a end |
#[](i) ⇒ Object
Delegate [] to the underlying array. This is needed because Virtus redefine [] as well
96 97 98 99 100 101 |
# File 'lib/lims-core/base.rb', line 96 def [](i) case i when Fixnum then self.content[i] else super(i) end end |
#[]=(i, value) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/lims-core/base.rb', line 103 def []=(i, value) case i when Fixnum then self.content[i]=value else super(i, value) end end |
#content ⇒ Array
The underlying array. Use to everything which is not directly delegated
88 89 90 |
# File 'lib/lims-core/base.rb', line 88 def content @content end |
#each_content {|content| ... } ⇒ Object
iterate only between non empty lanes.
112 113 114 115 116 |
# File 'lib/lims-core/base.rb', line 112 def each_content @content.each do |content| yield content if content end end |
#initialize(*args, &block) ⇒ Object
69 70 71 72 |
# File 'lib/lims-core/base.rb', line 69 def initialize(*args, &block) super(*args, &block) initialize_array() end |