Class: HtmlSlicer::Mappers::Resizing
- Inherits:
-
Object
- Object
- HtmlSlicer::Mappers::Resizing
- Defined in:
- lib/html_slicer/mappers/resizing.rb
Overview
Resizing engine, generate and store slicing Map (hash)
Defined Under Namespace
Classes: Map
Instance Attribute Summary collapse
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(document, options) ⇒ Resizing
constructor
A new instance of Resizing.
- #resize_node(node) ⇒ Object
Methods included from Utilities::NodeMatchExtension
Methods included from Utilities::ParseNode
Constructor Details
#initialize(document, options) ⇒ Resizing
Returns a new instance of Resizing.
21 22 23 24 25 26 27 |
# File 'lib/html_slicer/mappers/resizing.rb', line 21 def initialize(document, ) raise(TypeError, "::HTML::Document expected, '#{document.class}' passed") unless document.is_a?(::HTML::Document) raise(TypeError, "HtmlSlicer::Options expected, '#{.class}' passed") unless .is_a?(HtmlSlicer::Options) @options = @map = Map.new process!(document.root) end |
Instance Attribute Details
#map ⇒ Object (readonly)
Returns the value of attribute map.
5 6 7 |
# File 'lib/html_slicer/mappers/resizing.rb', line 5 def map @map end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/html_slicer/mappers/resizing.rb', line 5 def @options end |
Instance Method Details
#resize_node(node) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/html_slicer/mappers/resizing.rb', line 29 def resize_node(node) if w = @map.width(node) width(node) { w.to_s } end if h = @map.height(node) height(node) { h.to_s } end end |