Module: Glib::EnumHelper
- Included in:
- JsonUi::ViewBuilder::Fields::TimeZone
- Defined in:
- app/helpers/glib/enum_helper.rb
Instance Method Summary collapse
- #glib_enum_options(clazz, enum_field, keys: nil, include_hints: false) ⇒ Object
-
#glib_time_zone_options ⇒ Object
See en.wikipedia.org/wiki/List_of_tz_database_time_zones and description.
Instance Method Details
#glib_enum_options(clazz, enum_field, keys: nil, include_hints: false) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/helpers/glib/enum_helper.rb', line 3 def (clazz, enum_field, keys: nil, include_hints: false) enum_name = enum_field.to_s keys ||= clazz.defined_enums[enum_name].keys keys.map do |i| text = clazz.glib_enum_humanize(enum_field, i, include_hints: include_hints) { text: text, value: i } end end |
#glib_time_zone_options ⇒ Object
See en.wikipedia.org/wiki/List_of_tz_database_time_zones and description
13 14 15 16 17 18 19 20 |
# File 'app/helpers/glib/enum_helper.rb', line 13 def ActiveSupport::TimeZone.all.sort { |a, b| a.utc_offset <=> b.utc_offset }.collect { |tz| utc_offset = "#{tz.utc_offset >= 0 ? '+' : ''}#{tz.utc_offset / 60 / 60}h" { value: tz.tzinfo.identifier, text: "#{utc_offset} #{tz.name}" } } end |