Module: CWG::Params
Defined Under Namespace
Modules: ParamsSetup
Instance Method Summary (collapse)
- - (Object) config(&block)
- - (Object) delim_str
- - (Object) init_config
- - (Object) param(names)
- - (Object) param_internal(name)
- - (Object) param_method(values, name)
- - (Object) word_count_str
- - (Object) word_size_str
- - (Object) wpm_str
Instance Method Details
- (Object) config(&block)
66 67 68 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 66 def config( & block) instance_eval( & block) end |
- (Object) delim_str
82 83 84 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 82 def delim_str "#{'=' * Params.name.size}\n" end |
- (Object) init_config
38 39 40 41 42 43 44 45 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 38 def init_config config do param(ParamsSetup::CMDS + ParamsSetup::PRINT_COLOURS + ParamsSetup::VARS + ParamsSetup::BOOL_CMDS.collect {|cmd| cmd[0]}) end end |
- (Object) param(names)
60 61 62 63 64 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 60 def param(names) names.each do |name| param_internal name end end |
- (Object) param_internal(name)
52 53 54 55 56 57 58 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 52 def param_internal name attr_accessor name instance_variable_set("@#{name}", nil) define_method name do | * values| param_method values, name end end |
- (Object) param_method(values, name)
47 48 49 50 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 47 def param_method values, name value = values.first value ? self.send("#{name}=", value) : instance_variable_get("@#{name}") end |
- (Object) word_count_str
70 71 72 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 70 def word_count_str word_count ? "Word count: #{word_count}\n" : nil end |
- (Object) word_size_str
78 79 80 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 78 def word_size_str size ? "Word size: #{size}\n" : nil end |
- (Object) wpm_str
74 75 76 |
# File '/Users/martyn/cw/cw_clone/lib/cw/params.rb', line 74 def wpm_str "WPM: #{wpm}\n" end |