Class: HtmlSlicer::Mappers::Slicing

Inherits:
Object
  • Object
show all
Includes:
Utilities::NodeMatchExtension, Utilities::ParseNode
Defined in:
lib/html_slicer/mappers/slicing.rb

Overview

Slicing engine, generate and store resizing Map (hash)

Defined Under Namespace

Classes: Map

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities::NodeMatchExtension

#able_to?, #general_match

Methods included from Utilities::ParseNode

#parse

Constructor Details

#initialize(document, options) ⇒ Slicing

Returns a new instance of Slicing.

Raises:

  • (TypeError)


20
21
22
23
24
25
26
27
# File 'lib/html_slicer/mappers/slicing.rb', line 20

def initialize(document, options)
  raise(TypeError, "::HTML::Document expected, '#{document.class}' passed") unless document.is_a?(::HTML::Document)
  raise(TypeError, "HtmlSlicer::Options expected, '#{options.class}' passed") unless options.is_a?(HtmlSlicer::Options)
  @options = options
  @map = Map.new
  @slice_number = 1
  @options.unit.is_a?(Hash) ? process_by_node!(document.root) : process_by_text!(document.root)
end

Instance Attribute Details

#mapObject (readonly)

Returns the value of attribute map.



5
6
7
# File 'lib/html_slicer/mappers/slicing.rb', line 5

def map
  @map
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/html_slicer/mappers/slicing.rb', line 5

def options
  @options
end

#slice_numberObject (readonly)

Returns the value of attribute slice_number.



5
6
7
# File 'lib/html_slicer/mappers/slicing.rb', line 5

def slice_number
  @slice_number
end