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.



18154
18155
18156
18157
18158
18159
18160
# File 'lib/models/porcelain.rb', line 18154

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.



18150
18151
18152
# File 'lib/models/porcelain.rb', line 18150

def name
  @name
end

#valueObject

The value of this tag.



18152
18153
18154
# File 'lib/models/porcelain.rb', line 18152

def value
  @value
end

Instance Method Details

#to_json(options = {}) ⇒ Object



18162
18163
18164
18165
18166
18167
18168
# File 'lib/models/porcelain.rb', line 18162

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