Class: Tidyopt
- Inherits:
-
Object
- Object
- Tidyopt
- Defined in:
- lib/tidy/tidyopt.rb
Overview
Ruby interface to Tidylib options.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Reader for options (Hash syntax).
-
#[]=(name, value) ⇒ Object
Writer for options (Hash syntax).
-
#initialize(doc) ⇒ Tidyopt
constructor
Construct a new instance.
-
#method_missing(name, value = :none, *args) ⇒ Object
Reader/Writer for options (Object syntax).
Constructor Details
#initialize(doc) ⇒ Tidyopt
Construct a new instance.
7 8 9 |
# File 'lib/tidy/tidyopt.rb', line 7 def initialize(doc) @doc = doc end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, value = :none, *args) ⇒ Object
Reader/Writer for options (Object syntax).
25 26 27 28 29 |
# File 'lib/tidy/tidyopt.rb', line 25 def method_missing(name, value=:none, *args) name = name.to_s.gsub('=', '') return self[name] if value == :none self[name] = value end |
Instance Method Details
#[](name) ⇒ Object
Reader for options (Hash syntax).
13 14 15 |
# File 'lib/tidy/tidyopt.rb', line 13 def [](name) Tidylib.opt_get_value(@doc, name) end |
#[]=(name, value) ⇒ Object
Writer for options (Hash syntax).
19 20 21 |
# File 'lib/tidy/tidyopt.rb', line 19 def []=(name, value) Tidylib.opt_parse_value(@doc, name, value) end |