Module: EverydayPlugins::TypeHelper
- Defined in:
- lib/everyday-plugins/plugin.rb
Instance Method Summary collapse
- #basic_type(list, *args) ⇒ Object
- #complex_filter(list, options, symbol) ⇒ Object
- #flag_boolean(item, options) ⇒ Object
- #get_name(list) ⇒ Object
- #simple_type(list, *args) ⇒ Object
- #simple_type_with_result(list) ⇒ Object
Instance Method Details
#basic_type(list, *args) ⇒ Object
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/everyday-plugins/plugin.rb', line 123 def basic_type(list, *args) = Plugins.get_var :options list.any? { |item| if item[:block].nil? flag_boolean(item, ) else item[:block].call(, *args) end } end |
#complex_filter(list, options, symbol) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/everyday-plugins/plugin.rb', line 138 def complex_filter(list, , symbol) list.filtermap { |item| if item[:block].nil? if item[:options].has_key?(symbol) && flag_boolean(item, ) item[:options][symbol] else item[:options].has_key?(:option) && ![item[:options][:option]].nil? ? [item[:options][:option]] : false end else rval = item[:block].call() (rval.nil? || !rval) ? false : rval end } end |
#flag_boolean(item, options) ⇒ Object
134 135 136 |
# File 'lib/everyday-plugins/plugin.rb', line 134 def flag_boolean(item, ) item[:options].has_key?(:option) && [item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true) end |
#get_name(list) ⇒ Object
163 164 165 166 167 |
# File 'lib/everyday-plugins/plugin.rb', line 163 def get_name(list) = Plugins.get_var :options rval = complex_filter(list.sort_by { |v| -v[:options][:priority] }, , :name) (rval.nil? || rval.empty?) ? false : rval.first end |