Class: KDL::V1::Value

Inherits:
KDL::Value show all
Includes:
Methods
Defined in:
lib/kdl/v1/value.rb

Defined Under Namespace

Modules: Methods Classes: Boolean, Float, Int, NullImpl, String

Constant Summary collapse

Null =
NullImpl.new

Instance Attribute Summary

Attributes inherited from KDL::Value

#format, #type, #value

Class Method Summary collapse

Methods included from Methods

#==, #to_s, #to_v1, #to_v2, #version

Methods inherited from KDL::Value

#==, #as_type, #initialize, #inspect, #method_missing, #respond_to_missing?, #stringify_value, #to_s, #to_v2, #version

Constructor Details

This class inherits a constructor from KDL::Value

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class KDL::Value

Class Method Details

.from(value) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/kdl/v1/value.rb', line 79

def self.from(value)
  case value
  when ::String then String.new(value)
  when Integer then Int.new(value)
  when ::Float then Float.new(value)
  when TrueClass, FalseClass then Boolean.new(value)
  when NilClass then Null
  else raise Error("unsupported value type: #{value.class}")
  end
end