Class: String
- Inherits:
-
Object
show all
- Defined in:
- lib/everyday-cli-utils/format.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/everyday-cli-utils/format.rb', line 7
def method_missing(method, *args)
name = method.to_s
colors = 'black|red|green|yellow|blue|purple|cyan|white|none'
if (name =~ /format(_bold)?(_underline)?(?:_fg_(#{colors}))?(?:_bg_(#{colors}))?/).nil?
old_method_missing(method, *args)
else
EverydayCliUtils::Format::format(self, EverydayCliUtils::Format::build_string(!$1.nil?, !$2.nil?, $3.nil? ? nil : $3.to_sym, $4.nil? ? nil : $4.to_sym))
end
end
|
Instance Method Details
#mycenter(len, char = ' ') ⇒ Object
#old_method_missing ⇒ Object
4
|
# File 'lib/everyday-cli-utils/format.rb', line 4
alias :old_method_missing :method_missing
|
#old_respond_to? ⇒ Object
5
|
# File 'lib/everyday-cli-utils/format.rb', line 5
alias :old_respond_to? :respond_to?
|
#respond_to?(method) ⇒ Boolean
17
18
19
20
21
|
# File 'lib/everyday-cli-utils/format.rb', line 17
def respond_to?(method)
name = method.to_s
colors = 'black|red|green|yellow|blue|purple|cyan|white|none'
(!(name =~ /format(_bold)?(_underline)?(?:_fg_(#{colors}))?(?:_bg_(#{colors}))?/).nil?) || old_respond_to?(method)
end
|