Class: Hexp::List
Overview
A list of nodes
Class Method Summary (collapse)
-
+ (Hexp::List) [](*args)
Convenience constructor.
Instance Method Summary (collapse)
-
- (Boolean) eql?(other)
Value and type equality.
-
- (List) initialize(nodes)
constructor
Create new Hexp::List.
-
- (Object) inspect
private
String representation.
-
- (Array<Hexp::Node>) to_ary
Internal coercion to Array.
Constructor Details
- (List) initialize(nodes)
Create new Hexp::List
15 16 17 |
# File 'lib/hexp/list.rb', line 15 def initialize(nodes) super nodes.to_ary.freeze end |
Class Method Details
+ (Hexp::List) [](*args)
Convenience constructor
32 33 34 |
# File 'lib/hexp/list.rb', line 32 def self.[](*args) new(args) end |
Instance Method Details
- (Boolean) eql?(other)
Value and type equality
Hexp::List is mostly interchangeable with a plain Array, and so equality with `==` delegates to the underlying array, making `Hexp::List[] == []` true.
If you want a stronger comparison, than this version will compare both the value (in this case : contents), and the type.
79 80 81 |
# File 'lib/hexp/list.rb', line 79 def eql?(other) self == other && self.class == other.class end |
- (Object) inspect
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
String representation
This delegates to the underlying array, so it's not obvious from the output that this is a wrapping class. This is convenient when inspecting nested hexps, but probably something we want to solve differently.
45 46 47 |
# File 'lib/hexp/list.rb', line 45 def inspect __getobj__.inspect end |
- (Array<Hexp::Node>) to_ary
Internal coercion to Array
57 58 59 |
# File 'lib/hexp/list.rb', line 57 def to_ary __getobj__ end |