Class: Rubytypeformio::Link

Inherits:
Base
  • Object
show all
Defined in:
lib/rubytypeformio/link.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#compact, #pretty

Constructor Details

#initialize(rel, href) ⇒ Link

Returns a new instance of Link.



9
10
11
12
# File 'lib/rubytypeformio/link.rb', line 9

def initialize (rel, href)
  @rel = rel
  @href = href
end

Instance Attribute Details

#hrefObject

Returns the value of attribute href.



7
8
9
# File 'lib/rubytypeformio/link.rb', line 7

def href
  @href
end

#relObject

Returns the value of attribute rel.



7
8
9
# File 'lib/rubytypeformio/link.rb', line 7

def rel
  @rel
end

Class Method Details

.from_json(string) ⇒ Object



25
26
27
28
29
30
# File 'lib/rubytypeformio/link.rb', line 25

def self.from_json(string)
  data = JSON.load(string)
  obj = self.new( data["href"],
                  data["rel"])
  return obj
end

Instance Method Details

#to_hObject



18
19
20
21
22
23
# File 'lib/rubytypeformio/link.rb', line 18

def to_h
  return {
      :href => @href,
      :rel => @rel
  }
end

#to_jsonObject



14
15
16
# File 'lib/rubytypeformio/link.rb', line 14

def to_json
  JSON.dump(self.to_h)
end