Class: Journal::Data

Inherits:
Hash
  • Object
show all
Defined in:
lib/journal-cli/data.rb

Overview

Data handler

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#questionsObject (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_dataHash

Convert Data object to a hash

Returns:

  • (Hash)

    Data representation of the object.



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