Class: Twilic::Core::Model::Value

Inherits:
Data
  • Object
show all
Defined in:
lib/twilic/core/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arrObject (readonly)

Returns the value of attribute arr

Returns:

  • (Object)

    the current value of arr



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def arr
  @arr
end

#binObject (readonly)

Returns the value of attribute bin

Returns:

  • (Object)

    the current value of bin



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def bin
  @bin
end

#boolObject (readonly)

Returns the value of attribute bool

Returns:

  • (Object)

    the current value of bool



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def bool
  @bool
end

#f64Object (readonly)

Returns the value of attribute f64

Returns:

  • (Object)

    the current value of f64



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def f64
  @f64
end

#i64Object (readonly)

Returns the value of attribute i64

Returns:

  • (Object)

    the current value of i64



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def i64
  @i64
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def kind
  @kind
end

#mapObject (readonly)

Returns the value of attribute map

Returns:

  • (Object)

    the current value of map



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def map
  @map
end

#strObject (readonly)

Returns the value of attribute str

Returns:

  • (Object)

    the current value of str



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def str
  @str
end

#u64Object (readonly)

Returns the value of attribute u64

Returns:

  • (Object)

    the current value of u64



56
57
58
# File 'lib/twilic/core/model.rb', line 56

def u64
  @u64
end

Instance Method Details

#clone_valueObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/twilic/core/model.rb', line 61

def clone_value
  case kind
  when ValueKind::NULL, ValueKind::BOOL, ValueKind::I64, ValueKind::U64, ValueKind::F64, ValueKind::STRING
    self
  when ValueKind::BINARY
    with(bin: bin.b.dup)
  when ValueKind::ARRAY
    with(arr: arr.map(&:clone_value))
  when ValueKind::MAP
    with(map: map.map { |e| MapEntry.new(e.key, e.value.clone_value) })
  else
    new(kind: ValueKind::NULL)
  end
end

#scalar?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/twilic/core/model.rb', line 57

def scalar?
  kind != ValueKind::ARRAY && kind != ValueKind::MAP
end