Class: Pandoku::Format
- Inherits:
-
Object
show all
- Defined in:
- lib/pandoku/format.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Format
Returns a new instance of Format.
17
18
19
20
21
|
# File 'lib/pandoku/format.rb', line 17
def initialize(options = {})
@options = self.class.default_options
keys = @options.keys
@options.merge!(Hash[options.select {|k, v| keys.include?(k) }])
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6
7
8
|
# File 'lib/pandoku/format.rb', line 6
def options
@options
end
|
Class Method Details
.default_options ⇒ Object
13
14
15
|
# File 'lib/pandoku/format.rb', line 13
def self.default_options
{}
end
|
.name ⇒ Object
8
9
10
11
|
# File 'lib/pandoku/format.rb', line 8
def self.name
raise NotImplementedError,
'Format.name should be overrided to return Symbol'
end
|
Instance Method Details
#cliopts ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/pandoku/format.rb', line 23
def cliopts
escapeshellarg = lambda do |arg|
"'" + arg.gsub(/[^\\]'/) {|s| %<#{s.chars.first}\\'> } + "'"
end
@options.select {|k, v| v } \
.collect {|p| %<--#{p[0].gsub('_', '-')}> +
(p[1] != true ? %<=#{p[1]}> : '') } \
.join(' ')
end
|