Class: Fountain::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/fountain/note.rb

Overview

Fountain Note

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Note

Returns a new instance of Note.

Parameters:

  • data (Hash)

    Raw note data



14
15
16
# File 'lib/fountain/note.rb', line 14

def initialize(data)
  @raw_data = Util.stringify_hash_keys data
end

Instance Attribute Details

#raw_dataObject (readonly)

Raw note data



9
10
11
# File 'lib/fountain/note.rb', line 9

def raw_data
  @raw_data
end

Instance Method Details

#contentObject

Content



24
25
26
# File 'lib/fountain/note.rb', line 24

def content
  raw_data['content']
end

#created_atObject

Created at



29
30
31
# File 'lib/fountain/note.rb', line 29

def created_at
  Time.parse raw_data['created_at']
end

#idObject

Note ID



19
20
21
# File 'lib/fountain/note.rb', line 19

def id
  raw_data['id']
end

#inspectObject



45
46
47
48
49
50
51
52
# File 'lib/fountain/note.rb', line 45

def inspect
  format(
    '#<%<class_name>s:0x%<object_id>p @id="%<id>s">',
    class_name: self.class.name,
    object_id: object_id,
    id: id
  )
end

#updated_atObject

Updated at



34
35
36
# File 'lib/fountain/note.rb', line 34

def updated_at
  Time.parse raw_data['updated_at']
end

#userObject

User



39
40
41
42
43
# File 'lib/fountain/note.rb', line 39

def user
  return unless raw_data['user'].is_a? Hash

  User.new raw_data['user']
end