Class: Paru::PandocFilter::Value
Overview
A Value node that represents some sort of metadata about block or inline nodes
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.
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'] if contents.has_key? 'c' then @value = contents['c'] else @value = 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() return { "t" => ast_type, "c" => if type_encodes_value? then nil else @value end } end |
#type_encodes_value? ⇒ Boolean
101 102 103 |
# File 'lib/paru/filter/value.rb', line 101 def type_encodes_value?() return @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? then @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? then @type = new_value else @value = new_value end end |