Class: Widgetify::ImageInfo
- Inherits:
-
Object
- Object
- Widgetify::ImageInfo
- Defined in:
- lib/parser/image_parser.rb
Instance Method Summary collapse
-
#initialize(html_doc) ⇒ ImageInfo
constructor
A new instance of ImageInfo.
- #look_for_images ⇒ Object
Constructor Details
#initialize(html_doc) ⇒ ImageInfo
Returns a new instance of ImageInfo.
9 10 11 12 |
# File 'lib/parser/image_parser.rb', line 9 def initialize(html_doc) @img_doc = html_doc.xpath("//img") @image = [] end |
Instance Method Details
#look_for_images ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/parser/image_parser.rb', line 14 def look_for_images image = [] @img_doc.each do |attr| img_hash = { } img_hash["src"] = attr.get_attribute("src") img_hash["width"] = attr.get_attribute("width") img_hash["height"] = attr.get_attribute("height") img_hash["alt"] = attr.get_attribute("alt") img_hash["align"] = attr.get_attribute("align") img_hash["class"] = attr.get_attribute("class") img_hash["id"] = attr.get_attribute("id") img_hash["lang"] = attr.get_attribute("lang") img_hash["style"] = attr.get_attribute("style") img_hash["title"] = attr.get_attribute("title") image << img_hash end image end |