Class: Airspace::Metadata
- Inherits:
-
Object
- Object
- Airspace::Metadata
- Defined in:
- lib/airspace/metadata.rb
Overview
Metdata is ‘data about a dataset.’ These are key pieces of information we need to store with the data then later retrieve with the data.
Constant Summary collapse
- DEFAULT_PAGES_PER_CHUNK =
5
Instance Attribute Summary collapse
-
#expires_in_seconds ⇒ Object
readonly
Returns the value of attribute expires_in_seconds.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
-
#pages_per_chunk ⇒ Object
readonly
Returns the value of attribute pages_per_chunk.
Instance Method Summary collapse
- #chunk_count ⇒ Object
- #chunker ⇒ Object
-
#initialize(expires_in_seconds: nil, page_count: 0, pages_per_chunk: DEFAULT_PAGES_PER_CHUNK) ⇒ Metadata
constructor
A new instance of Metadata.
- #to_json ⇒ Object
Constructor Details
#initialize(expires_in_seconds: nil, page_count: 0, pages_per_chunk: DEFAULT_PAGES_PER_CHUNK) ⇒ Metadata
Returns a new instance of Metadata.
20 21 22 23 24 25 26 |
# File 'lib/airspace/metadata.rb', line 20 def initialize(expires_in_seconds: nil, page_count: 0, pages_per_chunk: DEFAULT_PAGES_PER_CHUNK) @expires_in_seconds = expires_in_seconds ? expires_in_seconds.to_i : nil @page_count = page_count.to_i @pages_per_chunk = pages_per_chunk ? pages_per_chunk.to_i : DEFAULT_PAGES_PER_CHUNK freeze end |
Instance Attribute Details
#expires_in_seconds ⇒ Object (readonly)
Returns the value of attribute expires_in_seconds.
16 17 18 |
# File 'lib/airspace/metadata.rb', line 16 def expires_in_seconds @expires_in_seconds end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
16 17 18 |
# File 'lib/airspace/metadata.rb', line 16 def page_count @page_count end |
#pages_per_chunk ⇒ Object (readonly)
Returns the value of attribute pages_per_chunk.
16 17 18 |
# File 'lib/airspace/metadata.rb', line 16 def pages_per_chunk @pages_per_chunk end |
Instance Method Details
#chunk_count ⇒ Object
32 33 34 |
# File 'lib/airspace/metadata.rb', line 32 def chunk_count chunker.count(page_count) end |
#chunker ⇒ Object
28 29 30 |
# File 'lib/airspace/metadata.rb', line 28 def chunker ::Airspace::Chunker.new(pages_per_chunk) end |
#to_json ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/airspace/metadata.rb', line 36 def to_json { expires_in_seconds: expires_in_seconds, page_count: page_count, pages_per_chunk: pages_per_chunk }.to_json end |