Class: Widgetify::Base
- Inherits:
-
Object
- Object
- Widgetify::Base
- Defined in:
- lib/widgetify.rb
Instance Attribute Summary collapse
-
#parse_result ⇒ Object
readonly
Returns the value of attribute parse_result.
Instance Method Summary collapse
-
#initialize(url, options = {}, *args) ⇒ Base
constructor
A new instance of Base.
- #parse_all ⇒ Object
- #parse_html ⇒ Object
- #parse_oembed ⇒ Object
- #parse_open_graph ⇒ Object
Constructor Details
#initialize(url, options = {}, *args) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 |
# File 'lib/widgetify.rb', line 13 def initialize(url, = {}, *args) @html_doc = Nokogiri::HTML(open(url)) @parse_result = { } @options = @options[:url] = url parse_all if args.length == 0 args.each{ |arg| send(arg.to_sym)} if args.length > 0 end |
Instance Attribute Details
#parse_result ⇒ Object (readonly)
Returns the value of attribute parse_result.
11 12 13 |
# File 'lib/widgetify.rb', line 11 def parse_result @parse_result end |
Instance Method Details
#parse_all ⇒ Object
34 35 36 37 38 |
# File 'lib/widgetify.rb', line 34 def parse_all parse_open_graph parse_html end |
#parse_html ⇒ Object
30 31 32 |
# File 'lib/widgetify.rb', line 30 def parse_html @parse_result['html'] = Widgetify::HTMLParser.new(@html_doc) end |
#parse_oembed ⇒ Object
26 27 28 |
# File 'lib/widgetify.rb', line 26 def @parse_result['oembed'] = Widgetify::OembedParser.new(@html_doc, @options) end |
#parse_open_graph ⇒ Object
22 23 24 |
# File 'lib/widgetify.rb', line 22 def parse_open_graph @parse_result['open_graph'] = Widgetify::OpenGraphParser.new(@html_doc) end |