Class: CSS
- Inherits:
-
Object
- Object
- CSS
- Defined in:
- lib/css.rb
Instance Method Summary collapse
-
#property(method, *args, &block) ⇒ Object
Write a css property declaration with the name of the called method.
-
#selector(selector, &block) ⇒ Object
Write a css selector declaration to $stdout.
-
#style(&block) ⇒ Object
Send a message to the instance_eval method of a CSS instace.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
23 24 25 26 |
# File 'lib/css.rb', line 23 def method_missing name, *args, &block send(:selector, *args, &block) if block send(:property, name, *args, &block) if args[0] and !block end |
Instance Method Details
#property(method, *args, &block) ⇒ Object
Write a css property declaration with the name of the called method
17 18 19 |
# File 'lib/css.rb', line 17 def property method, *args, &block $stdout.write "#{method.to_s.gsub('_', '-')}:#{args[0]};" end |
#selector(selector, &block) ⇒ Object
Write a css selector declaration to $stdout
11 12 13 |
# File 'lib/css.rb', line 11 def selector selector, &block $stdout.write "#{selector}{"; yield; $stdout.write "}" end |
#style(&block) ⇒ Object
Send a message to the instance_eval method of a CSS instace. It is just an Alias.
5 6 7 |
# File 'lib/css.rb', line 5 def style &block send :instance_eval, &block end |