Class: BrDanfe::DanfeLib::NfeLib::Entrega

Inherits:
Object
  • Object
show all
Defined in:
lib/br_danfe/danfe_lib/nfe_lib/entrega.rb

Constant Summary collapse

Y_POSITION =
12.92
MAXIMUM_SIZE_FOR_STREET =
319

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdf, xml) ⇒ Entrega

Returns a new instance of Entrega.



8
9
10
11
12
13
14
15
16
17
# File 'lib/br_danfe/danfe_lib/nfe_lib/entrega.rb', line 8

def initialize(pdf, xml)
  @pdf = pdf
  @xml = xml

  @y_position = Y_POSITION
  @ltitle = @y_position - 0.42
  @l1 = @y_position
  @l2 = @y_position + LINE_HEIGHT
  @l3 = @y_position + (LINE_HEIGHT * 2)
end

Class Method Details

.delivery_local?(xml) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/br_danfe/danfe_lib/nfe_lib/entrega.rb', line 28

def self.delivery_local?(xml)
  doc = xml.is_a?(BrDanfe::XML) ? xml : Nokogiri::XML(xml)
  doc.css('entrega/xLgr').text.present?
end

Instance Method Details

#renderObject



19
20
21
22
23
24
25
26
# File 'lib/br_danfe/danfe_lib/nfe_lib/entrega.rb', line 19

def render
  if Entrega.delivery_local?(@xml)
    @pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'entrega.title'
    render_line1
    render_line2
    render_line3
  end
end