Class: Grocer::Pushpackager::Icon
- Inherits:
-
Object
- Object
- Grocer::Pushpackager::Icon
- Defined in:
- lib/grocer/pushpackager/icon.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #from_file(file) ⇒ Object
-
#initialize(size) ⇒ Icon
constructor
A new instance of Icon.
- #valid? ⇒ Boolean
Constructor Details
#initialize(size) ⇒ Icon
Returns a new instance of Icon.
5 6 7 8 |
# File 'lib/grocer/pushpackager/icon.rb', line 5 def initialize(size) @name = "icon_#{size}.png" self end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
4 5 6 |
# File 'lib/grocer/pushpackager/icon.rb', line 4 def contents @contents end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/grocer/pushpackager/icon.rb', line 4 def name @name end |
Instance Method Details
#from_file(file) ⇒ Object
10 11 12 13 14 |
# File 'lib/grocer/pushpackager/icon.rb', line 10 def from_file file @contents = file.read file.close self end |
#valid? ⇒ Boolean
16 17 18 19 20 |
# File 'lib/grocer/pushpackager/icon.rb', line 16 def valid? raise ArgumentError, "invalid icon name" unless @name raise ArgumentError, "missing contents" unless @contents true end |