Class: IconView

Inherits:
UILabel
  • Object
show all
Defined in:
lib/project/views/icon_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/project/views/icon_view.rb', line 2

def name
  @name
end

Instance Method Details

#hexObject



19
20
21
# File 'lib/project/views/icon_view.rb', line 19

def hex
  unicode ? unicode.hex.chr(Encoding::UTF_8) : ''
end

#icon_mappingsObject



27
28
29
# File 'lib/project/views/icon_view.rb', line 27

def icon_mappings
  @_icon_mappings ||= BW::JSON.parse(json_data.to_str)
end

#initObject



4
5
6
7
8
9
10
11
# File 'lib/project/views/icon_view.rb', line 4

def init
  super.tap do |view|
    view.font            = MotionForm.icon_font
    view.backgroundColor = UIColor.clearColor
    view.textColor       = UIColor.grayColor
    view.textAlignment   = NSTextAlignmentCenter
  end
end

#json_dataObject



31
32
33
# File 'lib/project/views/icon_view.rb', line 31

def json_data
  NSData.dataWithContentsOfFile(json_path)
end

#json_pathObject



35
36
37
# File 'lib/project/views/icon_view.rb', line 35

def json_path
  NSBundle.mainBundle.pathForResource('font_icons', ofType: 'json')
end

#unicodeObject



23
24
25
# File 'lib/project/views/icon_view.rb', line 23

def unicode
  icon_mappings[name]
end