Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/dynalist/node.rb
Constant Summary collapse
- COLOR =
{ 0 => :white, 1 => :red, 2 => :orange, 3 => :yellow, 4 => :green, 5 => :blue, 6 => :purple }.freeze
Instance Attribute Summary collapse
-
#checkbox ⇒ Object
readonly
Returns the value of attribute checkbox.
-
#checked ⇒ Object
readonly
Returns the value of attribute checked.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#file_id ⇒ Object
readonly
Returns the value of attribute file_id.
-
#heading ⇒ Object
readonly
Returns the value of attribute heading.
-
#node_id ⇒ Object
readonly
Returns the value of attribute node_id.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
Instance Method Summary collapse
- #attributes ⇒ Object
- #color ⇒ Object
- #created_at ⇒ Object
- #include(**query) ⇒ Object
-
#initialize(file_id: nil, id: nil, content: nil, note: nil, created: nil, modified: nil, children: [], checked: false, checkbox: false, heading: 0, color: 0) ⇒ Node
constructor
A new instance of Node.
- #updated_at ⇒ Object
Constructor Details
#initialize(file_id: nil, id: nil, content: nil, note: nil, created: nil, modified: nil, children: [], checked: false, checkbox: false, heading: 0, color: 0) ⇒ Node
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dynalist/node.rb', line 16 def initialize(file_id: nil, id: nil, content: nil, note: nil, created: nil, modified: nil, children: [], checked: false, checkbox: false, heading: 0, color: 0) @file_id = file_id @node_id = id @content = content @note = note @created = created @modified = modified @children_ids = children @checked = checked @checkbox = checkbox @heading = heading @color_number = color end |
Instance Attribute Details
#checkbox ⇒ Object (readonly)
Returns the value of attribute checkbox.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def checkbox @checkbox end |
#checked ⇒ Object (readonly)
Returns the value of attribute checked.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def checked @checked end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def children @children end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def content @content end |
#file_id ⇒ Object (readonly)
Returns the value of attribute file_id.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def file_id @file_id end |
#heading ⇒ Object (readonly)
Returns the value of attribute heading.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def heading @heading end |
#node_id ⇒ Object (readonly)
Returns the value of attribute node_id.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def node_id @node_id end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
14 15 16 |
# File 'lib/dynalist/node.rb', line 14 def note @note end |
Instance Method Details
#attributes ⇒ Object
55 56 57 58 59 |
# File 'lib/dynalist/node.rb', line 55 def attributes instance_variables.map do |key| [key[1..-1].to_sym, instance_variable_get(key)] end.to_h end |
#color ⇒ Object
39 40 41 |
# File 'lib/dynalist/node.rb', line 39 def color COLOR[@color_number] end |
#created_at ⇒ Object
47 48 49 |
# File 'lib/dynalist/node.rb', line 47 def created_at to_time(@created) end |
#include(**query) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/dynalist/node.rb', line 30 def include(**query) query.each do |key, value| next if instance_variable_get("@#{key}") == value return false end return true end |
#updated_at ⇒ Object
43 44 45 |
# File 'lib/dynalist/node.rb', line 43 def updated_at to_time(@modified) end |