Class: UrlParser::OptionSetter

Inherits:
Object
  • Object
show all
Defined in:
lib/url_parser/option_setter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &blk) ⇒ OptionSetter

Returns a new instance of OptionSetter.



8
9
10
11
# File 'lib/url_parser/option_setter.rb', line 8

def initialize(options = {}, &blk)
  @options  = options
  @blk      = blk
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



42
43
44
# File 'lib/url_parser/option_setter.rb', line 42

def method_missing(*args)
  # no-op
end

Instance Attribute Details

#blkObject (readonly)

Returns the value of attribute blk.



4
5
6
# File 'lib/url_parser/option_setter.rb', line 4

def blk
  @blk
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/url_parser/option_setter.rb', line 6

def options
  @options
end

Instance Method Details

#canonicalize!Object



21
22
23
# File 'lib/url_parser/option_setter.rb', line 21

def canonicalize!
  options[:canonicalize] = true
end

#clean!Object



29
30
31
32
33
34
# File 'lib/url_parser/option_setter.rb', line 29

def clean!
  unescape!
  unembed!
  canonicalize!
  normalize!
end

#normalize!Object



25
26
27
# File 'lib/url_parser/option_setter.rb', line 25

def normalize!
  options[:normalize] = true
end

#to_hashObject Also known as: to_h



36
37
38
39
# File 'lib/url_parser/option_setter.rb', line 36

def to_hash
  blk.call(self) if blk
  self.options
end

#unembed!Object



17
18
19
# File 'lib/url_parser/option_setter.rb', line 17

def unembed!
  options[:unembed] = true
end

#unescape!Object



13
14
15
# File 'lib/url_parser/option_setter.rb', line 13

def unescape!
  options[:unescape] = true
end