Class: Paru::PandocFilter::Value
Overview
A Value node that represents some sort of metadata about block or inline nodes
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#ast_type ⇒ String
The AST type of this Node.
-
#initialize(contents) ⇒ Value
constructor
Create a new Value with contents.
-
#is_block? ⇒ Boolean
Is this node a block?.
-
#is_inline? ⇒ Boolean
Is this node an inline node?.
-
#to_ast ⇒ Hash
Create an AST representation of this Node.
- #type_encodes_value? ⇒ Boolean
-
#value ⇒ Any
Get the encoded value.
-
#value=(new_value) ⇒ Object
Set the encoded value.
Methods inherited from Node
#ast_contents, #can_act_as_both_block_and_inline?, #each, from_markdown, #get_replacement, #has_been_replaced?, #has_block?, #has_children?, #has_class?, #has_inline?, #has_parent?, #has_string?, #is_leaf?, #is_node?, #is_root?, #markdown, #markdown=, #toMetadata, #to_s, #type
Methods included from ASTManipulation
#append, #delete, #each_depth_first, #find_index, #get, #insert, #prepend, #remove_at, #replace, #replace_at
Constructor Details
#initialize(contents) ⇒ Value
Create a new Value with contents. Also indicate if this node has inline children or block children.
37 38 39 40 41 42 43 44 45 |
# File 'lib/paru/filter/value.rb', line 37 def initialize(contents) @type = contents['t'] @value = if contents.key? 'c' contents['c'] else VALUE_ENCODED_IN_TYPE_NAME end end |
Instance Method Details
#ast_type ⇒ String
The AST type of this Node
86 87 88 |
# File 'lib/paru/filter/value.rb', line 86 def ast_type @type end |
#is_block? ⇒ Boolean
Is this node a block?
72 73 74 |
# File 'lib/paru/filter/value.rb', line 72 def is_block? false end |
#is_inline? ⇒ Boolean
Is this node an inline node?
79 80 81 |
# File 'lib/paru/filter/value.rb', line 79 def is_inline? false end |
#to_ast ⇒ Hash
Create an AST representation of this Node
93 94 95 96 97 98 |
# File 'lib/paru/filter/value.rb', line 93 def to_ast { 't' => ast_type, 'c' => type_encodes_value? ? nil : @value } end |
#type_encodes_value? ⇒ Boolean
100 101 102 |
# File 'lib/paru/filter/value.rb', line 100 def type_encodes_value? @value == VALUE_ENCODED_IN_TYPE_NAME end |
#value ⇒ Any
Get the encoded value
50 51 52 53 54 55 56 |
# File 'lib/paru/filter/value.rb', line 50 def value if type_encodes_value? @type else @value end end |
#value=(new_value) ⇒ Object
Set the encoded value
61 62 63 64 65 66 67 |
# File 'lib/paru/filter/value.rb', line 61 def value=(new_value) if type_encodes_value? @type = new_value else @value = new_value end end |