Class: YiffSpace::Images::Banner::Base
- Inherits:
-
Object
- Object
- YiffSpace::Images::Banner::Base
- Defined in:
- lib/yiffspace/images/banner/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, type) ⇒ Base
constructor
A new instance of Base.
- #serializable_hash ⇒ Object
- #update ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(id, type) ⇒ Base
Returns a new instance of Base.
11 12 13 14 |
# File 'lib/yiffspace/images/banner/base.rb', line 11 def initialize(id, type) @id = id @type = type end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/yiffspace/images/banner/base.rb', line 9 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/yiffspace/images/banner/base.rb', line 9 def type @type end |
Class Method Details
.from_json(data) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/yiffspace/images/banner/base.rb', line 28 def self.from_json(data) raise(ArgumentError, "invalid data") if data.blank? data = JSON.parse(data) if data.is_a?(String) data = ::YiffSpace::Utils::OpenHash.from(data) return Banner.find_type(data.type).from_json(data) if self == Base new(data.id) end |
.type ⇒ Object
7 |
# File 'lib/yiffspace/images/banner/base.rb', line 7 def self.type = nil |
Instance Method Details
#serializable_hash ⇒ Object
24 25 26 |
# File 'lib/yiffspace/images/banner/base.rb', line 24 def serializable_hash(*) { "id" => @id, "type" => @type } end |
#update ⇒ Object
20 21 22 |
# File 'lib/yiffspace/images/banner/base.rb', line 20 def update(*) raise(NotImplementedError) end |
#url ⇒ Object
16 17 18 |
# File 'lib/yiffspace/images/banner/base.rb', line 16 def url raise(NotImplementedError) end |