Class: Erlang::List
- Inherits:
-
Array
- Object
- Array
- Erlang::List
- Defined in:
- lib/erlang/list.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #improper? ⇒ Boolean
- #inspect ⇒ Object
- #pretty_inspect ⇒ Object
- #pretty_print(q) ⇒ Object
Instance Attribute Details
#tail(value = nil) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/erlang/list.rb', line 9 def tail(value = nil) if value self.tail = value self else @tail ||= [] end end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/erlang/list.rb', line 34 def ==(other) if improper? and not other.respond_to?(:tail) false elsif other.respond_to?(:tail) super && tail == other.tail else super end end |
#improper? ⇒ Boolean
5 6 7 |
# File 'lib/erlang/list.rb', line 5 def improper? tail != [] end |
#inspect ⇒ Object
18 19 20 |
# File 'lib/erlang/list.rb', line 18 def inspect "#<#{self.class.name} #{super[0..-2]} | #{tail.inspect}]>" end |
#pretty_inspect ⇒ Object
22 23 24 |
# File 'lib/erlang/list.rb', line 22 def pretty_inspect "#<#{self.class.name} #{super[0..-2]}>\n" end |
#pretty_print(q) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/erlang/list.rb', line 26 def pretty_print(q) q.group(1, '[', " | #{tail.inspect}]") { q.seplist(self) { |v| q.pp v } } end |