Class: Graft::Json::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/graft/lib/graft/json/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source = nil) ⇒ Attribute

Returns a new instance of Attribute.



7
8
9
10
# File 'lib/graft/lib/graft/json/attribute.rb', line 7

def initialize(name, source = nil)
  @name   = name
  @source = source.nil? ? @name.to_s : source
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/graft/lib/graft/json/attribute.rb', line 5

def name
  @name
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/graft/lib/graft/json/attribute.rb', line 5

def source
  @source
end

Instance Method Details

#value_from(data) ⇒ Object



12
13
14
# File 'lib/graft/lib/graft/json/attribute.rb', line 12

def value_from(data)
  data/source
end