Class: SDM::Tag

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, value: nil) ⇒ Tag

Returns a new instance of Tag.



16001
16002
16003
16004
16005
16006
16007
# File 'lib/models/porcelain.rb', line 16001

def initialize(
  name: nil,
  value: nil
)
  @name = name == nil ? "" : name
  @value = value == nil ? "" : value
end

Instance Attribute Details

#nameObject

The name or key of this tag. Each name can only refer to one value on a tagged entity.



15997
15998
15999
# File 'lib/models/porcelain.rb', line 15997

def name
  @name
end

#valueObject

The value of this tag.



15999
16000
16001
# File 'lib/models/porcelain.rb', line 15999

def value
  @value
end

Instance Method Details

#to_json(options = {}) ⇒ Object



16009
16010
16011
16012
16013
16014
16015
# File 'lib/models/porcelain.rb', line 16009

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end