Class: Lhm::ChunkFinder
- Inherits:
-
Object
- Object
- Lhm::ChunkFinder
- Defined in:
- lib/lhm/chunk_finder.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
-
#initialize(migration, connection = nil, options = {}) ⇒ ChunkFinder
constructor
A new instance of ChunkFinder.
- #table_empty? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(migration, connection = nil, options = {}) ⇒ ChunkFinder
Returns a new instance of ChunkFinder.
3 4 5 6 7 8 |
# File 'lib/lhm/chunk_finder.rb', line 3 def initialize(migration, connection = nil, = {}) @migration = migration @connection = connection @start = [:start] || select_start_from_db @limit = [:limit] || select_limit_from_db end |
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit.
10 11 12 |
# File 'lib/lhm/chunk_finder.rb', line 10 def limit @limit end |
#start ⇒ Object
Returns the value of attribute start.
10 11 12 |
# File 'lib/lhm/chunk_finder.rb', line 10 def start @start end |
Instance Method Details
#table_empty? ⇒ Boolean
12 13 14 |
# File 'lib/lhm/chunk_finder.rb', line 12 def table_empty? start.nil? && limit.nil? end |
#validate ⇒ Object
16 17 18 19 20 |
# File 'lib/lhm/chunk_finder.rb', line 16 def validate if start > limit raise ArgumentError, "impossible chunk options (limit (#{limit.inspect} must be greater than start (#{start.inspect})" end end |