Class: InstaScraper::HTML::Media
- Inherits:
-
InstaScraper::HTML
- Object
- InstaScraper::HTML
- InstaScraper::HTML::Media
- Defined in:
- lib/insta_scraper/html/media.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(code = nil, html = nil) ⇒ Media
constructor
A new instance of Media.
- #url ⇒ Object
Methods inherited from InstaScraper::HTML
Constructor Details
#initialize(code = nil, html = nil) ⇒ Media
Returns a new instance of Media.
5 6 7 8 9 10 |
# File 'lib/insta_scraper/html/media.rb', line 5 def initialize(code = nil, html = nil) raise ArgumentError, 'Provide a code or html string' if !code && !html @code = code @html = html end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/insta_scraper/html/media.rb', line 3 def code @code end |
Instance Method Details
#data ⇒ Object
16 17 18 19 20 21 |
# File 'lib/insta_scraper/html/media.rb', line 16 def data @data ||= Hashie::Mash.new(::JSON.parse(shared_data)) .extend(Hashie::Extensions::DeepFetch) .extend(Hashie::Extensions::DeepFind) end |
#url ⇒ Object
12 13 14 |
# File 'lib/insta_scraper/html/media.rb', line 12 def url "https://www.instagram.com/p/#{code}/" end |