Class: JvYAML::JvYAMLi::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/jvyaml.rb

Direct Known Subclasses

Map, Scalar, Seq

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#styleObject

Returns the value of attribute style.



140
141
142
# File 'lib/jvyaml.rb', line 140

def style
  @style
end

#type_idObject

Returns the value of attribute type_id.



141
142
143
# File 'lib/jvyaml.rb', line 141

def type_id
  @type_id
end

#valueObject

Returns the value of attribute value.



139
140
141
# File 'lib/jvyaml.rb', line 139

def value
  @value
end

Class Method Details

.from_internal(internal) ⇒ Object



155
156
157
158
159
160
161
162
163
164
# File 'lib/jvyaml.rb', line 155

def self.from_internal(internal)
  case internal
  when org.jvyamlb.nodes.ScalarNode
    Scalar.new(internal.tag, internal.value, internal.style.chr)
  when org.jvyamlb.nodes.MappingNode
    Map.new(internal.tag, internal.value.inject({}) {|h, obj| h[from_internal(obj[0])] = from_internal(obj[1]); h}, internal.flow_style)
  when org.jvyamlb.nodes.SequenceNode
    Seq.new(internal.tag, internal.value.map {|obj| from_internal(obj)}, internal.flow_style)
  end
end

Instance Method Details

#to_sObject



151
152
153
# File 'lib/jvyaml.rb', line 151

def to_s
  JvYAML.dump(self)
end

#to_strObject



147
148
149
# File 'lib/jvyaml.rb', line 147

def to_str
  JvYAML.dump(self)
end

#transformObject



143
144
145
# File 'lib/jvyaml.rb', line 143

def transform
  org.jruby.ext.jvyaml.JRubyConstructor.new(self, nil).construct_document(to_internal)
end