Class: SerpCheap::Ad
- Inherits:
-
Object
- Object
- SerpCheap::Ad
- Defined in:
- lib/serpcheap/models.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#displayed_link ⇒ Object
readonly
Returns the value of attribute displayed_link.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#sitelinks ⇒ Object
readonly
Returns the value of attribute sitelinks.
-
#snippet ⇒ Object
readonly
Returns the value of attribute snippet.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(position:, title:, link:, block:, displayed_link: nil, snippet: nil, sitelinks: nil) ⇒ Ad
constructor
A new instance of Ad.
Constructor Details
#initialize(position:, title:, link:, block:, displayed_link: nil, snippet: nil, sitelinks: nil) ⇒ Ad
Returns a new instance of Ad.
53 54 55 56 57 58 59 60 61 |
# File 'lib/serpcheap/models.rb', line 53 def initialize(position:, title:, link:, block:, displayed_link: nil, snippet: nil, sitelinks: nil) @position = position @title = title @link = link @block = block @displayed_link = displayed_link @snippet = snippet @sitelinks = sitelinks end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
51 52 53 |
# File 'lib/serpcheap/models.rb', line 51 def block @block end |
#displayed_link ⇒ Object (readonly)
Returns the value of attribute displayed_link.
51 52 53 |
# File 'lib/serpcheap/models.rb', line 51 def displayed_link @displayed_link end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
51 52 53 |
# File 'lib/serpcheap/models.rb', line 51 def link @link end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
51 52 53 |
# File 'lib/serpcheap/models.rb', line 51 def position @position end |
#sitelinks ⇒ Object (readonly)
Returns the value of attribute sitelinks.
51 52 53 |
# File 'lib/serpcheap/models.rb', line 51 def sitelinks @sitelinks end |
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
51 52 53 |
# File 'lib/serpcheap/models.rb', line 51 def snippet @snippet end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
51 52 53 |
# File 'lib/serpcheap/models.rb', line 51 def title @title end |
Class Method Details
.from_hash(d) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/serpcheap/models.rb', line 63 def self.from_hash(d) sl = d["sitelinks"] new( position: d["position"].to_i, title: d["title"].to_s, link: d["link"].to_s, block: d["block"].to_s, displayed_link: d["displayedLink"], snippet: d["snippet"], sitelinks: sl.is_a?(Array) ? sl.map { |s| Sitelink.from_hash(s) } : nil ) end |