Class: BandCampBX::Entities::Base
- Inherits:
-
Object
- Object
- BandCampBX::Entities::Base
- Defined in:
- lib/bandcampbx/entities/base.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
Constructor Details
#initialize(hash) ⇒ Base
Returns a new instance of Base.
14 15 16 17 |
# File 'lib/bandcampbx/entities/base.rb', line 14 def initialize(hash) check_for_errors(hash) map_instance_variables(hash) end |
Class Method Details
.keys ⇒ Object
10 11 12 |
# File 'lib/bandcampbx/entities/base.rb', line 10 def self.keys self.mappings.keys end |
.map_decimal ⇒ Object
36 37 38 |
# File 'lib/bandcampbx/entities/base.rb', line 36 def self.map_decimal ->(val) { BigDecimal(val) } end |
.map_int ⇒ Object
32 33 34 |
# File 'lib/bandcampbx/entities/base.rb', line 32 def self.map_int ->(val) { val.to_i } end |
.map_time ⇒ Object
28 29 30 |
# File 'lib/bandcampbx/entities/base.rb', line 28 def self.map_time ->(val) { Time.parse(val) } end |
.setup_readers ⇒ Object
6 7 8 |
# File 'lib/bandcampbx/entities/base.rb', line 6 def self.setup_readers keys.each {|k| attr_reader k.to_sym } end |
Instance Method Details
#inspect ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bandcampbx/entities/base.rb', line 19 def inspect inspect_string = "#<#{self.class}:#{self.object_id} " self.class.keys.each do |key| inspect_string << "#{key}: #{send(key).inspect} " end inspect_string << " >" inspect_string end |