Class: Deliveries::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/deliveries/label.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw: nil, url: nil) ⇒ Label

Returns a new instance of Label.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
# File 'lib/deliveries/label.rb', line 5

def initialize(raw: nil, url: nil)
  raise ArgumentError, 'Both raw and url cannot be nil' if raw.nil? && url.nil?

  @raw = raw
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/deliveries/label.rb', line 3

def url
  @url
end

Instance Method Details

#rawObject



12
13
14
15
16
17
18
# File 'lib/deliveries/label.rb', line 12

def raw
  if @raw
    @raw
  elsif @url
    @raw = URI.parse(@url).read.force_encoding('binary')
  end
end