Class: Kuhsaft::ImageSize

Inherits:
Object
  • Object
show all
Defined in:
app/models/kuhsaft/image_size.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#heightObject

Returns the value of attribute height.



3
4
5
# File 'app/models/kuhsaft/image_size.rb', line 3

def height
  @height
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'app/models/kuhsaft/image_size.rb', line 3

def name
  @name
end

#widthObject

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

.allObject



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, teaser_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


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_sizeObject



42
43
44
45
46
47
48
# File 'app/models/kuhsaft/image_size.rb', line 42

def teaser_size
  @teaser_size ||= ImageSize.new.tap do |size|
    size.name = :teaser
    size.width = 320
    size.height = 180
  end
end

Instance Method Details

#labelObject



5
6
7
# File 'app/models/kuhsaft/image_size.rb', line 5

def label
  I18n.t("activerecord.attributes.kuhsaft/image_size.sizes.#{name}")
end