Class: Danica::Formatted
- Inherits:
-
Object
show all
- Defined in:
- lib/danica/formatted.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(content, **options) ⇒ Formatted
Returns a new instance of Formatted.
6
7
8
9
|
# File 'lib/danica/formatted.rb', line 6
def initialize(content, **options)
@content = content
@options = options
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/danica/formatted.rb', line 47
def method_missing(method, *args)
value = content.public_send(method, *args)
return value unless value.is_a?(Danica::Common)
repack(value)
end
|
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4
5
6
|
# File 'lib/danica/formatted.rb', line 4
def content
@content
end
|
#options ⇒ Object
Returns the value of attribute options.
4
5
6
|
# File 'lib/danica/formatted.rb', line 4
def options
@options
end
|
Instance Method Details
#==(other) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/danica/formatted.rb', line 15
def ==(other)
return false unless other.class == self.class
other.content == content &&
other.format == format
end
|
22
23
24
|
# File 'lib/danica/formatted.rb', line 22
def format
options[:format]
end
|
#repack(object) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/danica/formatted.rb', line 26
def repack(object)
self.class.new(
object,
options
)
end
|
#to(format, **opts) ⇒ Object
41
42
43
|
# File 'lib/danica/formatted.rb', line 41
def to(format, **opts)
content.to(format, options.merge(opts))
end
|
#to_gnu(**opts) ⇒ Object
37
38
39
|
# File 'lib/danica/formatted.rb', line 37
def to_gnu(**opts)
to(:gnu, **opts)
end
|
#to_s ⇒ Object
11
12
13
|
# File 'lib/danica/formatted.rb', line 11
def to_s
content.to(format, options)
end
|
#to_tex(**opts) ⇒ Object
33
34
35
|
# File 'lib/danica/formatted.rb', line 33
def to_tex(**opts)
to(:tex, **opts)
end
|