Class: Warehouse::Item::Code
- Inherits:
-
Struct
- Object
- Struct
- Warehouse::Item::Code
- Defined in:
- lib/warehouse/item/code.rb
Instance Attribute Summary collapse
-
#barcode ⇒ Object
Returns the value of attribute barcode.
-
#code ⇒ Object
Returns the value of attribute code.
-
#code_2 ⇒ Object
Returns the value of attribute code_2.
-
#price ⇒ Object
Returns the value of attribute price.
-
#qty ⇒ Object
Returns the value of attribute qty.
-
#title ⇒ Object
Returns the value of attribute title.
-
#title_en ⇒ Object
Returns the value of attribute title_en.
Class Method Summary collapse
Instance Method Summary collapse
- #barcode? ⇒ Boolean
- #code? ⇒ Boolean
- #deep_dup ⇒ Object
- #is_free? ⇒ Boolean
-
#persisted? ⇒ Boolean
給 form 用的.
- #product ⇒ Object
- #random? ⇒ Boolean
- #single? ⇒ Boolean
- #to_h ⇒ Object
- #type ⇒ Object
Instance Attribute Details
#barcode ⇒ Object
Returns the value of attribute barcode
3 4 5 |
# File 'lib/warehouse/item/code.rb', line 3 def end |
#code ⇒ Object
Returns the value of attribute code
3 4 5 |
# File 'lib/warehouse/item/code.rb', line 3 def code @code end |
#code_2 ⇒ Object
Returns the value of attribute code_2
3 4 5 |
# File 'lib/warehouse/item/code.rb', line 3 def code_2 @code_2 end |
#price ⇒ Object
Returns the value of attribute price
3 4 5 |
# File 'lib/warehouse/item/code.rb', line 3 def price @price end |
#qty ⇒ Object
Returns the value of attribute qty
3 4 5 |
# File 'lib/warehouse/item/code.rb', line 3 def qty @qty end |
#title ⇒ Object
Returns the value of attribute title
3 4 5 |
# File 'lib/warehouse/item/code.rb', line 3 def title @title end |
#title_en ⇒ Object
Returns the value of attribute title_en
3 4 5 |
# File 'lib/warehouse/item/code.rb', line 3 def title_en @title_en end |
Class Method Details
.build(fragment) ⇒ Object
5 6 7 8 9 |
# File 'lib/warehouse/item/code.rb', line 5 def self.build(fragment) qty = fragment["qty"].nil? ? 0 : fragment["qty"].to_i Code.new(fragment["code"], fragment["title"], qty, fragment["price"].to_i, fragment["barcode"], fragment["code_2"], fragment["title_en"]) end |
Instance Method Details
#barcode? ⇒ Boolean
15 16 17 |
# File 'lib/warehouse/item/code.rb', line 15 def false end |
#code? ⇒ Boolean
19 20 21 |
# File 'lib/warehouse/item/code.rb', line 19 def code? true end |
#deep_dup ⇒ Object
47 48 49 |
# File 'lib/warehouse/item/code.rb', line 47 def deep_dup self.class.new(code, title, qty, price, , code_2, title_en) end |
#is_free? ⇒ Boolean
11 12 13 |
# File 'lib/warehouse/item/code.rb', line 11 def is_free? price == 0 end |
#persisted? ⇒ Boolean
給 form 用的
52 |
# File 'lib/warehouse/item/code.rb', line 52 def persisted?; false end |
#product ⇒ Object
53 |
# File 'lib/warehouse/item/code.rb', line 53 def product; end |
#random? ⇒ Boolean
27 28 29 |
# File 'lib/warehouse/item/code.rb', line 27 def random? false end |
#single? ⇒ Boolean
31 32 33 |
# File 'lib/warehouse/item/code.rb', line 31 def single? true end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/warehouse/item/code.rb', line 35 def to_h { 'code' => code, 'title' => title, 'qty' => qty, 'price' => price, 'barcode' => , 'code_2' => code_2, 'title_en' => title_en } end |
#type ⇒ Object
23 24 25 |
# File 'lib/warehouse/item/code.rb', line 23 def type 'single' end |