Class: AnyValue::ArrayOf

Inherits:
Anything show all
Defined in:
lib/any_value.rb

Instance Method Summary collapse

Methods inherited from Anything

#^, #to_ary, #to_str

Constructor Details

#initialize(element) ⇒ ArrayOf

Returns a new instance of ArrayOf.



185
186
187
188
189
190
191
192
# File 'lib/any_value.rb', line 185

def initialize(element)
  unless element.is_a?(Anything)
    raise ArgumentError, "invalid argument: #{element.inspect}" 
  end

  super
  @element = element
end

Instance Method Details

#==(o) ⇒ Object



194
195
196
# File 'lib/any_value.rb', line 194

def ==(o)
  o.all? { |x| x == @element }
end

#inspectObject



198
199
200
# File 'lib/any_value.rb', line 198

def inspect
  "#<ArrayOf #{@element.inspect}>"
end