Class: HTMLEntities::Encoder

Inherits:
Object
  • Object
show all
Defined in:
lib/htmlentities/encoder.rb

Overview

:nodoc:

Constant Summary collapse

INSTRUCTIONS =
[:basic, :named, :decimal, :hexadecimal]

Instance Method Summary collapse

Constructor Details

#initialize(flavor, instructions) ⇒ Encoder

Returns a new instance of Encoder.



7
8
9
10
11
12
13
# File 'lib/htmlentities/encoder.rb', line 7

def initialize(flavor, instructions)
  @flavor = flavor
  instructions = [:basic] if instructions.empty?
  validate_instructions instructions
  build_basic_entity_encoder instructions
  build_extended_entity_encoder instructions
end

Instance Method Details

#encode(source) ⇒ Object



15
16
17
18
19
20
# File 'lib/htmlentities/encoder.rb', line 15

def encode(source)
  minimize_encoding(
    replace_extended(
      replace_basic(
        prepare(source))))
end