Class: Postsvg::Model::Literals::ArrayLiteral
- Inherits:
-
Object
- Object
- Postsvg::Model::Literals::ArrayLiteral
- Includes:
- Enumerable
- Defined in:
- lib/postsvg/model/literals/array.rb
Overview
Bracketed array literal: [1 2 3]. Elements may be any
literal or operator.
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](idx) ⇒ Object
- #accept(visitor, ctx) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(elements = []) ⇒ ArrayLiteral
constructor
A new instance of ArrayLiteral.
- #length ⇒ Object
Constructor Details
#initialize(elements = []) ⇒ ArrayLiteral
Returns a new instance of ArrayLiteral.
13 14 15 16 |
# File 'lib/postsvg/model/literals/array.rb', line 13 def initialize(elements = []) @elements = elements.freeze freeze end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
11 12 13 |
# File 'lib/postsvg/model/literals/array.rb', line 11 def elements @elements end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
30 31 32 |
# File 'lib/postsvg/model/literals/array.rb', line 30 def ==(other) other.is_a?(ArrayLiteral) && other.elements == @elements end |
#[](idx) ⇒ Object
24 |
# File 'lib/postsvg/model/literals/array.rb', line 24 def [](idx) = @elements[idx] |
#accept(visitor, ctx) ⇒ Object
26 27 28 |
# File 'lib/postsvg/model/literals/array.rb', line 26 def accept(visitor, ctx) visitor.visit_array(self, ctx) end |
#each(&block) ⇒ Object
18 19 20 |
# File 'lib/postsvg/model/literals/array.rb', line 18 def each(&block) @elements.each(&block) end |
#empty? ⇒ Boolean
23 |
# File 'lib/postsvg/model/literals/array.rb', line 23 def empty? = @elements.empty? |
#hash ⇒ Object
35 36 37 |
# File 'lib/postsvg/model/literals/array.rb', line 35 def hash @elements.hash end |
#length ⇒ Object
22 |
# File 'lib/postsvg/model/literals/array.rb', line 22 def length = @elements.length |