Class: HtmlSlicer::SlicingOptions

Inherits:
Options
  • Object
show all
Defined in:
lib/html_slicer/options.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from Options

#except, #only

Instance Method Summary collapse

Methods inherited from Options

#hexdigest, #string_value

Constructor Details

#initialize(options) ⇒ SlicingOptions

Returns a new instance of SlicingOptions.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/html_slicer/options.rb', line 30

def initialize(options)
  super(options)
  @unit = case options[:unit]
  when Hash, Regexp then options[:unit]
  when String then /#{options[:unit]}/
  when nil then /&#?\w+;|\S/
  else raise "Invalid :unit definition '#{options[:unit].inspect}'"
  end
  @maximum = case options[:maximum]
  when Fixnum then
    if options[:maximum] > 0
      options[:maximum]
    else
      raise "Invalid :maximum definition. Has to be more than zero, '#{options[:unit].inspect}' passed"
    end
  when nil then case unit
                when String, Regexp then 300
                when Hash then 10
                else 2000
                end
  else raise "Invalid :maximum definition '#{options[:maximum].inspect}'"
  end
  @complete = case options[:complete]
  when Regexp then options[:complete]
  when nil then nil
  else raise "Invalid :complete option definition '#{options[:complete].inspect}'"
  end
  @limit = case options[:limit]
  when Fixnum, nil then options[:limit]
  else raise "Invalid :limit option definition '#{options[:limit].inspect}'"
  end
  @text_break = options[:text_break]
end

Instance Attribute Details

#completeObject (readonly)

Returns the value of attribute complete.



28
29
30
# File 'lib/html_slicer/options.rb', line 28

def complete
  @complete
end

#limitObject (readonly)

Returns the value of attribute limit.



28
29
30
# File 'lib/html_slicer/options.rb', line 28

def limit
  @limit
end

#maximumObject (readonly)

Returns the value of attribute maximum.



28
29
30
# File 'lib/html_slicer/options.rb', line 28

def maximum
  @maximum
end

#text_breakObject (readonly)

Returns the value of attribute text_break.



28
29
30
# File 'lib/html_slicer/options.rb', line 28

def text_break
  @text_break
end

#unitObject (readonly)

Returns the value of attribute unit.



28
29
30
# File 'lib/html_slicer/options.rb', line 28

def unit
  @unit
end