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
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/everyday-plugins/plugin.rb', line 121 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
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/everyday-plugins/plugin.rb', line 136 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
132 133 134 |
# File 'lib/everyday-plugins/plugin.rb', line 132 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
161 162 163 164 165 |
# File 'lib/everyday-plugins/plugin.rb', line 161 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 |