Class: GOBL::Map
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/gobl/map.rb
Overview
Base class for map structures in the GOBL Schema. A map is an unconstrained list of keys and values
Direct Known Subclasses
CBC::CodeMap, CBC::Meta, I18n::String, Schema::Object, Tax::Extensions
Instance Attribute Summary collapse
- #_map ⇒ Object private
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns the value associated with the given key.
- #as_json ⇒ Object private
-
#each ⇒ Object
Iterates over each key-value pair in the map.
-
#each_key ⇒ Object
Iterates over each key in the map.
-
#empty? ⇒ Boolean
Returns ‘true` if the number of entires in the map is zero, `false` otherwise.
-
#initialize(map) ⇒ Map
constructor
Initializes a new map struct that corresponds to a given Hash.
-
#length ⇒ Integer
Returns the number of entries in the map.
-
#values ⇒ Array
Returns an array with the values in the map.
Methods inherited from Struct
from_data, from_json!, #to_json
Constructor Details
#initialize(map) ⇒ Map
Initializes a new map struct that corresponds to a given Hash
18 19 20 21 |
# File 'lib/gobl/map.rb', line 18 def initialize(map) super() self._map = map end |
Instance Attribute Details
#_map ⇒ Object
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.
11 12 13 |
# File 'lib/gobl/map.rb', line 11 def _map @_map end |
Instance Method Details
#[](key) ⇒ Object
Returns the value associated with the given key
64 |
# File 'lib/gobl/map.rb', line 64 def_delegators :_map, :[], :each, :empty?, :length, :each_key, :values |
#as_json ⇒ Object
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.
24 25 26 |
# File 'lib/gobl/map.rb', line 24 def as_json(...) _map.as_json(...) end |
#each {|key, value| ... } ⇒ self #each ⇒ Enumerator
Iterates over each key-value pair in the map
64 |
# File 'lib/gobl/map.rb', line 64 def_delegators :_map, :[], :each, :empty?, :length, :each_key, :values |
#each {|key| ... } ⇒ self #each ⇒ Enumerator
Iterates over each key in the map
64 |
# File 'lib/gobl/map.rb', line 64 def_delegators :_map, :[], :each, :empty?, :length, :each_key, :values |
#empty? ⇒ Boolean
Returns ‘true` if the number of entires in the map is zero, `false` otherwise.
64 |
# File 'lib/gobl/map.rb', line 64 def_delegators :_map, :[], :each, :empty?, :length, :each_key, :values |
#length ⇒ Integer
Returns the number of entries in the map
64 |
# File 'lib/gobl/map.rb', line 64 def_delegators :_map, :[], :each, :empty?, :length, :each_key, :values |
#values ⇒ Array
Returns an array with the values in the map
64 |
# File 'lib/gobl/map.rb', line 64 def_delegators :_map, :[], :each, :empty?, :length, :each_key, :values |