Class: Remarkably::Engines::CSS
Instance Method Summary
collapse
-
#clear! ⇒ Object
-
#css_class(args, hash, &block) ⇒ Object
-
#css_id(args, hash, &block) ⇒ Object
-
#css_prefix(prefix, &block) ⇒ Object
-
#css_pseudo(args, hash, &block) ⇒ Object
-
#method!(sym, args, hash, &block) ⇒ Object
-
#to_s ⇒ Object
#initialize, #method_missing, #missing_method
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Remarkably::Base::Engine
Instance Method Details
#clear! ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/remarkably/engines/css.rb', line 57
def clear!
super
@css_prefix=''
@css_depth=0
@css_prefix_rendered=false
@css_first_use=true
end
|
#css_class(args, hash, &block) ⇒ Object
41
42
43
|
# File 'lib/remarkably/engines/css.rb', line 41
def css_class args, hash, &block
css_prefix ".", &block
end
|
#css_id(args, hash, &block) ⇒ Object
45
46
47
|
# File 'lib/remarkably/engines/css.rb', line 45
def css_id args, hash, &block
css_prefix "#", &block
end
|
#css_prefix(prefix, &block) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/remarkably/engines/css.rb', line 34
def css_prefix prefix, &block
@css_prefix << prefix
block.call
@css_prefix.chop!
self
end
|
#css_pseudo(args, hash, &block) ⇒ Object
49
50
51
|
# File 'lib/remarkably/engines/css.rb', line 49
def css_pseudo args, hash, &block
css_prefix ":", &block
end
|
#method!(sym, args, hash, &block) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/remarkably/engines/css.rb', line 6
def method! sym, args, hash, &block
sym = sym.to_s.downcase
sym = "##{sym}".chop if sym[-1].chr == '!'
sym = ".#{sym}".chop if sym[-1].chr == '?'
if block_given?
current_prefix = @css_prefix
@css_prefix = (@css_prefix+"#{sym}#{args.map{|a|a.to_s}.join} ")
@css_depth+=1
@css_prefix_rendered=false
block.call
@css_depth-=1
@css_prefix = current_prefix
else
unless @css_prefix_rendered
unless @css_first_use
@output.chop!
@output << "}"
end
@output << "\n#{@css_prefix}{"
@css_prefix_rendered = true
@css_first_use = false
end
@output << "#{sym.gsub('_','-')}:#{args.map{|a|a.to_s}.join(' ')};"
end
self
end
|
#to_s ⇒ Object
53
54
55
|
# File 'lib/remarkably/engines/css.rb', line 53
def to_s
"#{super.chop}}".strip+"\n"
end
|