Class: EZML::Options

Inherits:
Object show all
Defined in:
lib/ezml/options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_wrapperObject

Returns the value of attribute attr_wrapper.



36
37
38
# File 'lib/ezml/options.rb', line 36

def attr_wrapper
  @attr_wrapper
end

#autocloseObject

Returns the value of attribute autoclose.



37
38
39
# File 'lib/ezml/options.rb', line 37

def autoclose
  @autoclose
end

#cdataObject

Returns the value of attribute cdata.



49
50
51
# File 'lib/ezml/options.rb', line 49

def cdata
  @cdata
end

#compiler_classObject

Returns the value of attribute compiler_class.



51
52
53
# File 'lib/ezml/options.rb', line 51

def compiler_class
  @compiler_class
end

#encodingObject

Returns the value of attribute encoding.



38
39
40
# File 'lib/ezml/options.rb', line 38

def encoding
  @encoding
end

#escape_attrsObject

Returns the value of attribute escape_attrs.



39
40
41
# File 'lib/ezml/options.rb', line 39

def escape_attrs
  @escape_attrs
end

#escape_htmlObject

Returns the value of attribute escape_html.



40
41
42
# File 'lib/ezml/options.rb', line 40

def escape_html
  @escape_html
end

#filenameObject

Returns the value of attribute filename.



41
42
43
# File 'lib/ezml/options.rb', line 41

def filename
  @filename
end

#filtersObject

Returns the value of attribute filters.



53
54
55
# File 'lib/ezml/options.rb', line 53

def filters
  @filters
end

#formatObject

Returns the value of attribute format.



44
45
46
# File 'lib/ezml/options.rb', line 44

def format
  @format
end

#hyphenate_data_attrsObject

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

#lineObject

Returns the value of attribute line.



43
44
45
# File 'lib/ezml/options.rb', line 43

def line
  @line
end

#mime_typeObject

Returns the value of attribute mime_type.



45
46
47
# File 'lib/ezml/options.rb', line 45

def mime_type
  @mime_type
end

#parser_classObject

Returns the value of attribute parser_class.



50
51
52
# File 'lib/ezml/options.rb', line 50

def parser_class
  @parser_class
end

#preserveObject

Returns the value of attribute preserve.



46
47
48
# File 'lib/ezml/options.rb', line 46

def preserve
  @preserve
end

#remove_whitespaceObject

Returns the value of attribute remove_whitespace.



47
48
49
# File 'lib/ezml/options.rb', line 47

def remove_whitespace
  @remove_whitespace
end

#suppress_evalObject

Returns the value of attribute suppress_eval.



48
49
50
# File 'lib/ezml/options.rb', line 48

def suppress_eval
  @suppress_eval
end

#traceObject

Returns the value of attribute trace.



52
53
54
# File 'lib/ezml/options.rb', line 52

def trace
  @trace
end

Class Method Details

.buffer_defaultsObject



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_keysObject



18
19
20
# File 'lib/ezml/options.rb', line 18

def self.buffer_option_keys
  @buffer_option_keys
end

.defaultsObject



10
11
12
# File 'lib/ezml/options.rb', line 10

def self.defaults
  @defaults ||= EZML::TemplateEngine.options.to_hash.merge(encoding: 'UTF-8')
end

.valid_formatsObject



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(options)
  if options.is_a?(Options)
    options
  else
    Options.new(options)
  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_bufferObject



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

Returns:

  • (Boolean)


85
86
87
# File 'lib/ezml/options.rb', line 85

def html4?
  format == :html4
end

#html5?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/ezml/options.rb', line 89

def html5?
  format == :html5
end

#html?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/ezml/options.rb', line 81

def html?
  html4? or html5?
end

#xhtml?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/ezml/options.rb', line 77

def xhtml?
  not html?
end