Module: Ruflet::CupertinoIcons
- Defined in:
- lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb
Overview
Cupertino icon names, exposed as constants. Materialized on demand for the same reason as Ruflet::MaterialIcons -- see the note there.
Constant Summary collapse
- FALLBACK_ICONS =
{ HOME: "house", SEARCH: "search", SETTINGS: "gear", ADD: "add", CLOSE: "clear" }.freeze
Class Method Summary collapse
- .[](name) ⇒ Object
- .all ⇒ Object
- .const_missing(name) ⇒ Object
- .constants(_inherit = true) ⇒ Object
- .icons ⇒ Object
- .names ⇒ Object
- .random ⇒ Object
-
.resolve_constant(name) ⇒ Object
See Ruflet::MaterialIcons.resolve_constant.
Class Method Details
.[](name) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 35 def [](name) icon = icons[name.to_s.upcase.to_sym] return icon.to_s.downcase unless icon.nil? Ruflet::CupertinoIconLookup.canonical_name_for(name) || name.to_s end |
.all ⇒ Object
46 47 48 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 46 def all icons.values.map { |name| name.to_s.downcase } end |
.const_missing(name) ⇒ Object
72 73 74 75 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 72 def const_missing(name) resolved = resolve_constant(name) resolved.nil? ? super : resolved end |
.constants(_inherit = true) ⇒ Object
42 43 44 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 42 def constants(_inherit = true) icons.keys end |
.icons ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 21 def icons @icons ||= begin source = Ruflet::CupertinoIconLookup.icon_map if source.empty? FALLBACK_ICONS else source.keys.each_with_object({}) do |name, result| text = Ruflet::IconNames.constant_for(name) result[text.upcase.to_sym] = name end end.freeze end end |
.names ⇒ Object
54 55 56 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 54 def names icons.values end |
.random ⇒ Object
50 51 52 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 50 def random all.sample || "question_circle" end |
.resolve_constant(name) ⇒ Object
See Ruflet::MaterialIcons.resolve_constant.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb', line 60 def resolve_constant(name) return const_get(name) if const_defined?(name, false) return const_set(:ICONS, icons) if name == :ICONS key = name.to_s source = Ruflet::CupertinoIconLookup.icon_map return const_set(name, key.downcase) if source.key?(key) icon = icons[name] icon.nil? ? nil : const_set(name, icon.to_s.downcase) end |