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.



9215
9216
9217
9218
9219
9220
9221
# File 'lib/models/porcelain.rb', line 9215

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.



9211
9212
9213
# File 'lib/models/porcelain.rb', line 9211

def name
  @name
end

#valueObject

The value of this tag.



9213
9214
9215
# File 'lib/models/porcelain.rb', line 9213

def value
  @value
end

Instance Method Details

#to_json(options = {}) ⇒ Object



9223
9224
9225
9226
9227
9228
9229
# File 'lib/models/porcelain.rb', line 9223

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