Class: Journal::Data
- Inherits:
-
Hash
- Object
- Hash
- Journal::Data
- Defined in:
- lib/journal-cli/data.rb
Overview
Data handler
Instance Attribute Summary collapse
-
#questions ⇒ Object
readonly
Returns the value of attribute questions.
Instance Method Summary collapse
-
#initialize(questions) ⇒ Data
constructor
A new instance of Data.
-
#to_data ⇒ Hash
Convert Data object to a hash.
Constructor Details
#initialize(questions) ⇒ Data
Returns a new instance of Data.
8 9 10 11 |
# File 'lib/journal-cli/data.rb', line 8 def initialize(questions) @questions = questions super end |
Instance Attribute Details
#questions ⇒ Object (readonly)
Returns the value of attribute questions.
6 7 8 |
# File 'lib/journal-cli/data.rb', line 6 def questions @questions end |
Instance Method Details
#to_data ⇒ Hash
Convert Data object to a hash
18 19 20 21 22 23 24 |
# File 'lib/journal-cli/data.rb', line 18 def to_data output = {} @questions.each do |q| output[q["key"]] = self[q["key"]] end output end |