Class: FakeDynamo::Sack
- Inherits:
-
Object
- Object
- FakeDynamo::Sack
- Defined in:
- lib/fake_dynamo/sack.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
-
#max_size ⇒ Object
Returns the value of attribute max_size.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #add(item) ⇒ Object
- #has_space? ⇒ Boolean
-
#initialize(max_size = 1 * 1024 * 1024) ⇒ Sack
constructor
1 mb.
Constructor Details
#initialize(max_size = 1 * 1024 * 1024) ⇒ Sack
1 mb
5 6 7 8 |
# File 'lib/fake_dynamo/sack.rb', line 5 def initialize(max_size = 1 * 1024 * 1024) # 1 mb @size = 0 @max_size = max_size end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
3 4 5 |
# File 'lib/fake_dynamo/sack.rb', line 3 def item @item end |
#max_size ⇒ Object
Returns the value of attribute max_size.
3 4 5 |
# File 'lib/fake_dynamo/sack.rb', line 3 def max_size @max_size end |
#size ⇒ Object
Returns the value of attribute size.
3 4 5 |
# File 'lib/fake_dynamo/sack.rb', line 3 def size @size end |
Instance Method Details
#add(item) ⇒ Object
10 11 12 |
# File 'lib/fake_dynamo/sack.rb', line 10 def add(item) @size += item.to_json.bytesize end |
#has_space? ⇒ Boolean
14 15 16 |
# File 'lib/fake_dynamo/sack.rb', line 14 def has_space? @size < @max_size end |