Class: ChatSDK::Cards::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/chat_sdk/cards/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, attributes: {}, children: []) ⇒ Node

Returns a new instance of Node.



8
9
10
11
12
# File 'lib/chat_sdk/cards/node.rb', line 8

def initialize(type, attributes: {}, children: [])
  @type = type
  @attributes = attributes
  @children = children.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/chat_sdk/cards/node.rb', line 6

def attributes
  @attributes
end

#childrenObject (readonly)

Returns the value of attribute children.



6
7
8
# File 'lib/chat_sdk/cards/node.rb', line 6

def children
  @children
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/chat_sdk/cards/node.rb', line 6

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
21
# File 'lib/chat_sdk/cards/node.rb', line 18

def ==(other)
  other.is_a?(Node) && type == other.type &&
    attributes == other.attributes && children == other.children
end

#fallback_textObject



14
15
16
# File 'lib/chat_sdk/cards/node.rb', line 14

def fallback_text
  collect_text.join("\n").strip
end