Class: Asciidoctor::Prawn::Extensions::Extent

Inherits:
Struct
  • Object
show all
Defined in:
lib/asciidoctor/pdf/ext/prawn/extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_page, current_column, current_cursor, from_page, from_column, from_cursor, to_page, to_cursor) ⇒ Extent

Returns a new instance of Extent.



36
37
38
39
40
41
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 36

def initialize current_page, current_column, current_cursor, from_page, from_column, from_cursor, to_page, to_cursor
  self.current = Position.new current_page, current_column, current_cursor
  self.from = Position.new from_page, from_column, from_cursor
  self.from = current if from == current
  self.to = Position.new to_page, nil, to_cursor
end

Instance Attribute Details

#currentObject

Returns the value of attribute current

Returns:

  • (Object)

    the current value of current



35
36
37
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 35

def current
  @current
end

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



35
36
37
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 35

def from
  @from
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



35
36
37
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 35

def to
  @to
end

Instance Method Details

#each_pageObject



43
44
45
46
47
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 43

def each_page
  from.page.upto to.page do |pgnum|
    yield pgnum == from.page && from, pgnum == to.page && to, pgnum
  end
end

#page_rangeObject



57
58
59
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 57

def page_range
  (from.page..to.page)
end

#single_page?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 49

def single_page?
  from.page == to.page
end

#single_page_heightObject



53
54
55
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 53

def single_page_height
  single_page? ? from.cursor - to.cursor : nil
end