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.



40
41
42
43
44
45
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 40

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



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

def current
  @current
end

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



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

def from
  @from
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



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

def to
  @to
end

Instance Method Details

#each_pageObject



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

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

#page_rangeObject



61
62
63
# File 'lib/asciidoctor/pdf/ext/prawn/extensions.rb', line 61

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

#single_page?Boolean

Returns:

  • (Boolean)


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

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

#single_page_heightObject



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

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