Class: Kuhsaft::ImageSize
- Inherits:
-
Object
- Object
- Kuhsaft::ImageSize
- Defined in:
- app/models/kuhsaft/image_size.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#name ⇒ Object
Returns the value of attribute name.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
- .add(name, width, height) ⇒ Object
- .all ⇒ Object
- .build_defaults! ⇒ Object
- .clear! ⇒ Object
- .find_by_name(name) ⇒ Object
- .gallery_size ⇒ Object
- .teaser_size ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'app/models/kuhsaft/image_size.rb', line 3 def height @height end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'app/models/kuhsaft/image_size.rb', line 3 def name @name end |
#width ⇒ Object
Returns the value of attribute width.
3 4 5 |
# File 'app/models/kuhsaft/image_size.rb', line 3 def width @width end |
Class Method Details
.add(name, width, height) ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/models/kuhsaft/image_size.rb', line 26 def add(name, width, height) @all << ImageSize.new.tap do |size| size.name = name.to_sym size.width = width size.height = height end end |
.all ⇒ Object
10 11 12 |
# File 'app/models/kuhsaft/image_size.rb', line 10 def all @all ||= [] end |
.build_defaults! ⇒ Object
14 15 16 |
# File 'app/models/kuhsaft/image_size.rb', line 14 def build_defaults! @all = [gallery_size, ] end |
.clear! ⇒ Object
22 23 24 |
# File 'app/models/kuhsaft/image_size.rb', line 22 def clear! @all = [] end |
.find_by_name(name) ⇒ Object
18 19 20 |
# File 'app/models/kuhsaft/image_size.rb', line 18 def find_by_name(name) all.find { |size| size.name.to_s == name.to_s } end |
.gallery_size ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/models/kuhsaft/image_size.rb', line 34 def gallery_size @gallery_size ||= ImageSize.new.tap do |size| size.name = :gallery size.width = 960 size.height = 540 end end |
.teaser_size ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/models/kuhsaft/image_size.rb', line 42 def @teaser_size ||= ImageSize.new.tap do |size| size.name = :teaser size.width = 320 size.height = 180 end end |
Instance Method Details
#label ⇒ Object
5 6 7 |
# File 'app/models/kuhsaft/image_size.rb', line 5 def label I18n.t("activerecord.attributes.kuhsaft/image_size.sizes.#{name}") end |