Class: Arstotzka::KeyReader Private
- Inherits:
-
Object
- Object
- Arstotzka::KeyReader
- Includes:
- Base
- Defined in:
- lib/arstotzka/key_reader.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class responsible for reading values from a hash
Instance Attribute Summary collapse
- #base_key ⇒ Object readonly private private
- #hash ⇒ Object readonly private private
- #options ⇒ Object readonly private private
Instance Method Summary collapse
-
#initialize(hash, base_key, options_hash = {}) ⇒ KeyReader
constructor
private
Creates a new instance of Reader.
-
#read ⇒ Object
private
Reads value from hash key.
Methods included from Base
Constructor Details
#initialize(hash, base_key, options_hash = {}) ⇒ KeyReader
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.
Creates a new instance of Reader
15 16 17 18 19 20 |
# File 'lib/arstotzka/key_reader.rb', line 15 def initialize(hash, base_key, = {}) self. = @hash = hash @base_key = base_key end |
Instance Attribute Details
#base_key ⇒ Object (readonly, private)
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.
50 51 52 |
# File 'lib/arstotzka/key_reader.rb', line 50 def base_key @base_key end |
#hash ⇒ Object (readonly, private)
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.
50 51 52 |
# File 'lib/arstotzka/key_reader.rb', line 50 def hash @hash end |
#options ⇒ Object (readonly, private)
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.
50 51 52 |
# File 'lib/arstotzka/key_reader.rb', line 50 def @options end |
Instance Method Details
#read ⇒ 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.
Reads value from hash key
42 43 44 45 46 |
# File 'lib/arstotzka/key_reader.rb', line 42 def read raise Exception::KeyNotFound unless key? hash.key?(key) ? hash[key] : hash[key.to_sym] end |