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.



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

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

  super
  @element = element
end

Instance Method Details

#==(o) ⇒ Object



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

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

#inspectObject



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

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