Class: MdlSearch::Icon
- Inherits:
-
Object
- Object
- MdlSearch::Icon
- Defined in:
- lib/mdl_search/icon.rb
Class Attribute Summary collapse
-
.groups ⇒ Object
Returns the value of attribute groups.
-
.icons ⇒ Object
Returns the value of attribute icons.
Instance Attribute Summary collapse
-
#codepoint ⇒ Object
Returns the value of attribute codepoint.
-
#group ⇒ Object
Returns the value of attribute group.
-
#is_new ⇒ Object
Returns the value of attribute is_new.
-
#key ⇒ Object
Returns the value of attribute key.
-
#keywords ⇒ Object
Returns the value of attribute keywords.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #classic_browser_key ⇒ Object
- #hit_query?(value, query) ⇒ Boolean
- #include_value?(key, query) ⇒ Boolean
-
#initialize(key, name, codepoint, group, keywords, is_new) ⇒ Icon
constructor
A new instance of Icon.
- #modern_browser_key ⇒ Object
Constructor Details
#initialize(key, name, codepoint, group, keywords, is_new) ⇒ Icon
Returns a new instance of Icon.
8 9 10 11 12 13 14 15 |
# File 'lib/mdl_search/icon.rb', line 8 def initialize(key, name, codepoint, group, keywords, is_new) @key = key @name = name @codepoint = codepoint @group = group @keywords = keywords @is_new = is_new end |
Class Attribute Details
.groups ⇒ Object
Returns the value of attribute groups.
48 49 50 |
# File 'lib/mdl_search/icon.rb', line 48 def groups @groups end |
.icons ⇒ Object
Returns the value of attribute icons.
49 50 51 |
# File 'lib/mdl_search/icon.rb', line 49 def icons @icons end |
Instance Attribute Details
#codepoint ⇒ Object
Returns the value of attribute codepoint.
3 4 5 |
# File 'lib/mdl_search/icon.rb', line 3 def codepoint @codepoint end |
#group ⇒ Object
Returns the value of attribute group.
3 4 5 |
# File 'lib/mdl_search/icon.rb', line 3 def group @group end |
#is_new ⇒ Object
Returns the value of attribute is_new.
3 4 5 |
# File 'lib/mdl_search/icon.rb', line 3 def is_new @is_new end |
#key ⇒ Object
Returns the value of attribute key.
3 4 5 |
# File 'lib/mdl_search/icon.rb', line 3 def key @key end |
#keywords ⇒ Object
Returns the value of attribute keywords.
3 4 5 |
# File 'lib/mdl_search/icon.rb', line 3 def keywords @keywords end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/mdl_search/icon.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
51 52 53 |
# File 'lib/mdl_search/icon.rb', line 51 def all icons end |
.where(hash) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/mdl_search/icon.rb', line 55 def where(hash) return self.all if hash.nil? self.all.select do |icon| hash.all? do |key, val| icon.include_value?(key, val) end end end |
Instance Method Details
#classic_browser_key ⇒ Object
21 22 23 |
# File 'lib/mdl_search/icon.rb', line 21 def classic_browser_key "&#x#{@codepoint};" end |
#hit_query?(value, query) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mdl_search/icon.rb', line 34 def hit_query?(value, query) case query.class.name when 'String' value.to_s.downcase.include? query.downcase when 'TrueClass', 'FalseClass' value == query when 'Array' query.any? { |q| value.downcase.include? q.downcase } else false end end |
#include_value?(key, query) ⇒ Boolean
25 26 27 28 29 30 31 32 |
# File 'lib/mdl_search/icon.rb', line 25 def include_value?(key, query) value_of_key = instance_variable_get "@#{key}" if value_of_key.is_a? Array value_of_key.any? { |v| hit_query? v, query } else hit_query? value_of_key, query end end |
#modern_browser_key ⇒ Object
17 18 19 |
# File 'lib/mdl_search/icon.rb', line 17 def modern_browser_key @key end |