Class: Moticons::Icon

Inherits:
Object
  • Object
show all
Defined in:
lib/moticons/icon.rb

Constant Summary collapse

COLLECTION_CLASSES =
{
  awesome:    :FAKFontAwesome,
  foundation: :FAKFoundationIcons,
  ion:        :FAKIonIcons,
  zocial:     :FAKZocial,
  octicon:    :FAKOcticons,
  material:   :FAKMaterialIcons
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, name = nil, options = {}) ⇒ Icon

Returns a new instance of Icon.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/moticons/icon.rb', line 14

def initialize(collection, name = nil, options = {})
  if name.is_a?(Hash)
    options = name; name = nil
  end
  if name.nil?
    collection, name = collection.split('_', 2)
  end
  @collection = collection.to_sym
  @name = camelize(name).to_sym
  @size = options.fetch(:size, 42)
  @color = options.fetch(:color, UIColor.blackColor)

  create_instance
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



12
13
14
# File 'lib/moticons/icon.rb', line 12

def collection
  @collection
end

#colorObject (readonly)

Returns the value of attribute color.



12
13
14
# File 'lib/moticons/icon.rb', line 12

def color
  @color
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/moticons/icon.rb', line 12

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



12
13
14
# File 'lib/moticons/icon.rb', line 12

def size
  @size
end

Instance Method Details

#to_imageObject



29
30
31
# File 'lib/moticons/icon.rb', line 29

def to_image
  @instance.imageWithSize(CGSizeMake(size, size))
end

#to_stringObject



33
34
35
# File 'lib/moticons/icon.rb', line 33

def to_string
  @instance.attributedString
end