Class: EZML::Options
Instance Attribute Summary collapse
-
#attr_wrapper ⇒ Object
Returns the value of attribute attr_wrapper.
-
#autoclose ⇒ Object
Returns the value of attribute autoclose.
-
#cdata ⇒ Object
Returns the value of attribute cdata.
-
#compiler_class ⇒ Object
Returns the value of attribute compiler_class.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#escape_attrs ⇒ Object
Returns the value of attribute escape_attrs.
-
#escape_html ⇒ Object
Returns the value of attribute escape_html.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#format ⇒ Object
Returns the value of attribute format.
-
#hyphenate_data_attrs ⇒ Object
Returns the value of attribute hyphenate_data_attrs.
-
#line ⇒ Object
Returns the value of attribute line.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
-
#parser_class ⇒ Object
Returns the value of attribute parser_class.
-
#preserve ⇒ Object
Returns the value of attribute preserve.
-
#remove_whitespace ⇒ Object
Returns the value of attribute remove_whitespace.
-
#suppress_eval ⇒ Object
Returns the value of attribute suppress_eval.
-
#trace ⇒ Object
Returns the value of attribute trace.
Class Method Summary collapse
- .buffer_defaults ⇒ Object
- .buffer_option_keys ⇒ Object
- .defaults ⇒ Object
- .valid_formats ⇒ Object
- .wrap(options) ⇒ Object
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #for_buffer ⇒ Object
- #html4? ⇒ Boolean
- #html5? ⇒ Boolean
- #html? ⇒ Boolean
-
#initialize(values = {}, &block) ⇒ Options
constructor
A new instance of Options.
- #xhtml? ⇒ Boolean
Constructor Details
#initialize(values = {}, &block) ⇒ Options
Returns a new instance of Options.
55 56 57 58 59 |
# File 'lib/ezml/options.rb', line 55 def initialize(values = {}, &block) defaults.each {|k, v| instance_variable_set :"@#{k}", v} values.each {|k, v| send("#{k}=", v) if defaults.has_key?(k) && !v.nil?} yield if block_given? end |
Instance Attribute Details
#attr_wrapper ⇒ Object
Returns the value of attribute attr_wrapper.
36 37 38 |
# File 'lib/ezml/options.rb', line 36 def attr_wrapper @attr_wrapper end |
#autoclose ⇒ Object
Returns the value of attribute autoclose.
37 38 39 |
# File 'lib/ezml/options.rb', line 37 def autoclose @autoclose end |
#cdata ⇒ Object
Returns the value of attribute cdata.
49 50 51 |
# File 'lib/ezml/options.rb', line 49 def cdata @cdata end |
#compiler_class ⇒ Object
Returns the value of attribute compiler_class.
51 52 53 |
# File 'lib/ezml/options.rb', line 51 def compiler_class @compiler_class end |
#encoding ⇒ Object
Returns the value of attribute encoding.
38 39 40 |
# File 'lib/ezml/options.rb', line 38 def encoding @encoding end |
#escape_attrs ⇒ Object
Returns the value of attribute escape_attrs.
39 40 41 |
# File 'lib/ezml/options.rb', line 39 def escape_attrs @escape_attrs end |
#escape_html ⇒ Object
Returns the value of attribute escape_html.
40 41 42 |
# File 'lib/ezml/options.rb', line 40 def escape_html @escape_html end |
#filename ⇒ Object
Returns the value of attribute filename.
41 42 43 |
# File 'lib/ezml/options.rb', line 41 def filename @filename end |
#filters ⇒ Object
Returns the value of attribute filters.
53 54 55 |
# File 'lib/ezml/options.rb', line 53 def filters @filters end |
#format ⇒ Object
Returns the value of attribute format.
44 45 46 |
# File 'lib/ezml/options.rb', line 44 def format @format end |
#hyphenate_data_attrs ⇒ Object
Returns the value of attribute hyphenate_data_attrs.
42 43 44 |
# File 'lib/ezml/options.rb', line 42 def hyphenate_data_attrs @hyphenate_data_attrs end |
#line ⇒ Object
Returns the value of attribute line.
43 44 45 |
# File 'lib/ezml/options.rb', line 43 def line @line end |
#mime_type ⇒ Object
Returns the value of attribute mime_type.
45 46 47 |
# File 'lib/ezml/options.rb', line 45 def mime_type @mime_type end |
#parser_class ⇒ Object
Returns the value of attribute parser_class.
50 51 52 |
# File 'lib/ezml/options.rb', line 50 def parser_class @parser_class end |
#preserve ⇒ Object
Returns the value of attribute preserve.
46 47 48 |
# File 'lib/ezml/options.rb', line 46 def preserve @preserve end |
#remove_whitespace ⇒ Object
Returns the value of attribute remove_whitespace.
47 48 49 |
# File 'lib/ezml/options.rb', line 47 def remove_whitespace @remove_whitespace end |
#suppress_eval ⇒ Object
Returns the value of attribute suppress_eval.
48 49 50 |
# File 'lib/ezml/options.rb', line 48 def suppress_eval @suppress_eval end |
#trace ⇒ Object
Returns the value of attribute trace.
52 53 54 |
# File 'lib/ezml/options.rb', line 52 def trace @trace end |
Class Method Details
.buffer_defaults ⇒ Object
22 23 24 25 26 |
# File 'lib/ezml/options.rb', line 22 def self.buffer_defaults @buffer_defaults ||= buffer_option_keys.inject({}) do |hash, key| hash.merge(key => defaults[key]) end end |
.buffer_option_keys ⇒ Object
18 19 20 |
# File 'lib/ezml/options.rb', line 18 def self.buffer_option_keys @buffer_option_keys end |
.defaults ⇒ Object
10 11 12 |
# File 'lib/ezml/options.rb', line 10 def self.defaults @defaults ||= EZML::TemplateEngine..to_hash.merge(encoding: 'UTF-8') end |
.valid_formats ⇒ Object
14 15 16 |
# File 'lib/ezml/options.rb', line 14 def self.valid_formats @valid_formats end |
.wrap(options) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ezml/options.rb', line 28 def self.wrap() if .is_a?(Options) else Options.new() end end |
Instance Method Details
#[](key) ⇒ Object
61 62 63 |
# File 'lib/ezml/options.rb', line 61 def [](key) send key end |
#[]=(key, value) ⇒ Object
65 66 67 |
# File 'lib/ezml/options.rb', line 65 def []=(key, value) send "#{key}=", value end |
#for_buffer ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'lib/ezml/options.rb', line 124 def for_buffer self.class.buffer_option_keys.inject({}) do |hash, key| value = public_send(key) if self.class.buffer_defaults[key] != value hash[key] = value end hash end end |
#html4? ⇒ Boolean
85 86 87 |
# File 'lib/ezml/options.rb', line 85 def html4? format == :html4 end |
#html5? ⇒ Boolean
89 90 91 |
# File 'lib/ezml/options.rb', line 89 def html5? format == :html5 end |
#html? ⇒ Boolean
81 82 83 |
# File 'lib/ezml/options.rb', line 81 def html? html4? or html5? end |
#xhtml? ⇒ Boolean
77 78 79 |
# File 'lib/ezml/options.rb', line 77 def xhtml? not html? end |