Class: Bike::Radio
Overview
- Author
-
Akira FUNAI
- Copyright
-
Copyright © 2009 Akira FUNAI
Constant Summary
Constants inherited from Field
Instance Attribute Summary
Attributes inherited from Field
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(meta = {}) ⇒ Radio
constructor
A new instance of Radio.
Methods inherited from Field
#[], #[]=, #commit, #create, #default_action, #delete, #empty?, #find_ancestor, #get, h, #inspect, instance, #item, #load, #load_default, #meta_admins, #meta_client, #meta_folder, #meta_full_name, #meta_group, #meta_name, #meta_owner, #meta_owners, #meta_roles, #meta_sd, #meta_short_name, #pending?, #permit?, #post, #update, #val, #valid?, #workflow
Methods included from I18n
_, bindtextdomain, domain, domain=, find_msg, lang, lang=, merge_msg!, msg, n_, parse_msg, po_dir, po_dir=
Constructor Details
#initialize(meta = {}) ⇒ Radio
Returns a new instance of Radio.
8 9 10 11 12 |
# File 'lib/scalar/radio.rb', line 8 def initialize( = {}) [:mandatory] = [:tokens] && [:tokens].include?('mandatory') [:options] ||= [:max] && ([:min].to_i..[:max]).collect {|i| i.to_s } super end |
Instance Method Details
#errors ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/scalar/radio.rb', line 14 def errors if val.empty? my[:mandatory] ? [_('mandatory')] : [] else my[:options].include?(val) ? [] : [_('no such option')] end end |