Class: Postscript::Model::Literals::Dictionary
- Inherits:
-
Object
- Object
- Postscript::Model::Literals::Dictionary
- Defined in:
- lib/postscript/model/literals/dictionary.rb
Overview
Inline dictionary literal: << /Key (value) /Num 42 >>.
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](key) ⇒ Object
- #accept(visitor, ctx) ⇒ Object
- #each(&block) ⇒ Object
- #hash ⇒ Object
-
#initialize(entries = {}) ⇒ Dictionary
constructor
A new instance of Dictionary.
- #key?(key) ⇒ Boolean
Constructor Details
#initialize(entries = {}) ⇒ Dictionary
Returns a new instance of Dictionary.
10 11 12 13 |
# File 'lib/postscript/model/literals/dictionary.rb', line 10 def initialize(entries = {}) @entries = entries.dup.freeze freeze end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
8 9 10 |
# File 'lib/postscript/model/literals/dictionary.rb', line 8 def entries @entries end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
23 24 25 |
# File 'lib/postscript/model/literals/dictionary.rb', line 23 def ==(other) other.is_a?(Dictionary) && other.entries == @entries end |
#[](key) ⇒ Object
15 |
# File 'lib/postscript/model/literals/dictionary.rb', line 15 def [](key) = @entries[key] |
#accept(visitor, ctx) ⇒ Object
19 20 21 |
# File 'lib/postscript/model/literals/dictionary.rb', line 19 def accept(visitor, ctx) visitor.visit_dictionary(self, ctx) end |
#each(&block) ⇒ Object
17 |
# File 'lib/postscript/model/literals/dictionary.rb', line 17 def each(&block) = @entries.each(&block) |
#hash ⇒ Object
28 29 30 |
# File 'lib/postscript/model/literals/dictionary.rb', line 28 def hash @entries.hash end |
#key?(key) ⇒ Boolean
16 |
# File 'lib/postscript/model/literals/dictionary.rb', line 16 def key?(key) = @entries.key?(key) |