class Node

Constants

COLOR

Attributes

checkbox[R]
checked[R]
children[R]
content[R]
file_id[R]
heading[R]
node_id[R]
note[R]

Public Class Methods

new(file_id: nil, id: nil, content: nil, note: nil, created: nil, modified: nil, children: [], checked: false, checkbox: false, heading: 0, color: 0) click to toggle source
# 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

Public Instance Methods

attributes() click to toggle source
# 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() click to toggle source
# File lib/dynalist/node.rb, line 39
def color
  COLOR[@color_number]
end
created_at() click to toggle source
# File lib/dynalist/node.rb, line 47
def created_at
  to_time(@created)
end
include(**query) click to toggle source
# 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() click to toggle source
# File lib/dynalist/node.rb, line 43
def updated_at
  to_time(@modified)
end

Private Instance Methods

to_time(time) click to toggle source
# File lib/dynalist/node.rb, line 63
def to_time(time)
  Time.at(time / 1000, time % 1000 * 1000).utc
end