Class: Fragmenter::Fragment
- Inherits:
-
Object
- Object
- Fragmenter::Fragment
- Defined in:
- lib/fragmenter/fragment.rb
Instance Attribute Summary collapse
-
#blob ⇒ Object
readonly
Returns the value of attribute blob.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #content_type ⇒ Object
-
#initialize(blob, options) ⇒ Fragment
constructor
A new instance of Fragment.
- #number ⇒ Object
- #padded_number ⇒ Object
- #total ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(blob, options) ⇒ Fragment
Returns a new instance of Fragment.
5 6 7 8 |
# File 'lib/fragmenter/fragment.rb', line 5 def initialize(blob, ) @blob = blob @options = end |
Instance Attribute Details
#blob ⇒ Object (readonly)
Returns the value of attribute blob.
3 4 5 |
# File 'lib/fragmenter/fragment.rb', line 3 def blob @blob end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/fragmenter/fragment.rb', line 3 def @options end |
Instance Method Details
#content_type ⇒ Object
18 19 20 |
# File 'lib/fragmenter/fragment.rb', line 18 def content_type @content_type ||= [:content_type] || 'application/octet-stream' end |
#number ⇒ Object
10 11 12 |
# File 'lib/fragmenter/fragment.rb', line 10 def number @number ||= .fetch(:number, 1).to_i end |
#padded_number ⇒ Object
22 23 24 25 26 |
# File 'lib/fragmenter/fragment.rb', line 22 def padded_number digits = total.to_s.length "%0#{digits}d" % number.to_s end |
#total ⇒ Object
14 15 16 |
# File 'lib/fragmenter/fragment.rb', line 14 def total @total ||= .fetch(:total, 1).to_i end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/fragmenter/fragment.rb', line 28 def valid? valid_blob? && valid_number? && valid_total? && valid_content_type? end |