Class: Deliveries::Label
- Inherits:
-
Object
- Object
- Deliveries::Label
- Defined in:
- lib/deliveries/label.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(raw: nil, url: nil) ⇒ Label
constructor
A new instance of Label.
- #raw ⇒ Object
Constructor Details
#initialize(raw: nil, url: nil) ⇒ Label
Returns a new instance of Label.
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
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/deliveries/label.rb', line 3 def url @url end |
Instance Method Details
#raw ⇒ Object
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 |