Class: Noft::Model::Icon

Inherits:
Object
  • Object
show all
Defined in:
lib/noft/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



93
94
95
# File 'lib/noft/model.rb', line 93

def description
  @description
end

#display_stringObject

A human readable name for icon



92
93
94
# File 'lib/noft/model.rb', line 92

def display_string
  @display_string
end

#unicodeObject

The unicode that it was assigned inside the font.



96
97
98
# File 'lib/noft/model.rb', line 96

def unicode
  @unicode
end

Instance Method Details

#aliasesObject

Alternative aliases under which this icon may be known.



104
105
106
# File 'lib/noft/model.rb', line 104

def aliases
  @aliases ||= []
end

#categoriesObject

Categories which this Icon exists. Useful when displaying an icon sheet.



99
100
101
# File 'lib/noft/model.rb', line 99

def categories
  @categories ||= []
end

#read_from(data) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/noft/model.rb', line 108

def read_from(data)
  self.display_string = data['displayString'] if data['displayString']
  self.description = data['description'] if data['description']
  self.unicode = data['unicode'] if data['unicode']
  data['aliases'].each do |a|
    self.aliases << a
  end if data['aliases']
  data['categories'].each do |c|
    self.categories << c
  end if data['categories']
end

#to_hObject



120
121
122
123
124
125
126
127
128
129
# File 'lib/noft/model.rb', line 120

def to_h
  data = {}
  data[:displayString] = self.display_string if self.display_string
  data[:description] = self.description if self.description
  data[:aliases] = self.aliases unless self.aliases.empty?
  data[:categories] = self.categories unless self.categories.empty?
  data[:unicode] = self.unicode if self.unicode

  data
end