Class: Pagseguro::Charge::Link
- Inherits:
-
Object
- Object
- Pagseguro::Charge::Link
- Defined in:
- lib/pagseguro/charge/link.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
Returns the value of attribute href.
-
#media ⇒ Object
Returns the value of attribute media.
-
#rel ⇒ Object
Returns the value of attribute rel.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #image? ⇒ Boolean
-
#initialize ⇒ Link
constructor
A new instance of Link.
- #json? ⇒ Boolean
- #pdf? ⇒ Boolean
- #to_json(*options) ⇒ Object
Constructor Details
#initialize ⇒ Link
Returns a new instance of Link.
10 11 |
# File 'lib/pagseguro/charge/link.rb', line 10 def initialize end |
Instance Attribute Details
#href ⇒ Object
Returns the value of attribute href.
4 5 6 |
# File 'lib/pagseguro/charge/link.rb', line 4 def href @href end |
#media ⇒ Object
Returns the value of attribute media.
4 5 6 |
# File 'lib/pagseguro/charge/link.rb', line 4 def media @media end |
#rel ⇒ Object
Returns the value of attribute rel.
4 5 6 |
# File 'lib/pagseguro/charge/link.rb', line 4 def rel @rel end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/pagseguro/charge/link.rb', line 4 def type @type end |
Class Method Details
.fill_from_json(data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pagseguro/charge/link.rb', line 19 def self.fill_from_json(data) return if data.nil? link = new link.rel = data["rel"] link.href = data["href"] link.media = data["media"] link.type = data["type"] link end |
Instance Method Details
#as_json(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/pagseguro/charge/link.rb', line 30 def as_json(={}) { rel: @rel, href: @href, media: @media, type: @type } end |
#image? ⇒ Boolean
43 44 45 |
# File 'lib/pagseguro/charge/link.rb', line 43 def image? @media == 'application/image' end |
#json? ⇒ Boolean
47 48 49 |
# File 'lib/pagseguro/charge/link.rb', line 47 def json? @media == 'application/json' end |
#pdf? ⇒ Boolean
39 40 41 |
# File 'lib/pagseguro/charge/link.rb', line 39 def pdf? @media == 'application/pdf' end |
#to_json(*options) ⇒ Object
13 14 15 16 17 |
# File 'lib/pagseguro/charge/link.rb', line 13 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |