Class: CrazyHarry::Base

Inherits:
Object
  • Object
show all
Includes:
Change, Default, Foster, Redact, Translate, Truncate
Defined in:
lib/crazy_harry/base.rb

Constant Summary

Constants included from Redact

Redact::STRIP_METHODS

Constants included from Change

Change::BLOCK_CONVERSION_ELEMENTS

Constants included from Default

Default::TARGET_ELEMENTS

Instance Attribute Summary collapse

Attributes included from Translate

#add_attributes, #from_text, #to_text

Attributes included from Redact

#attributes, #tags, #unsafe

Attributes included from Change

#from, #to

Instance Method Summary collapse

Methods included from Truncate

#truncate!

Methods included from Foster

#foster!

Methods included from Translate

#translate!

Methods included from Redact

#redact!, #strip!

Methods included from Change

#change!

Methods included from Default

#convert_br_to_p!, #dedupe!, #no_blanks!

Constructor Details

#initialize(opts = {}) ⇒ Base

Returns a new instance of Base.



12
13
14
15
# File 'lib/crazy_harry/base.rb', line 12

def initialize(opts = {})
  self.fragment = Loofah.fragment(opts.delete(:fragment)) if opts.has_key?(:fragment)
  self.steps = []
end

Instance Attribute Details

#fragmentObject

Returns the value of attribute fragment.



10
11
12
# File 'lib/crazy_harry/base.rb', line 10

def fragment
  @fragment
end

#scopeObject

Returns the value of attribute scope.



10
11
12
# File 'lib/crazy_harry/base.rb', line 10

def scope
  @scope
end

#stepsObject

Returns the value of attribute steps.



10
11
12
# File 'lib/crazy_harry/base.rb', line 10

def steps
  @steps
end

#textObject

Returns the value of attribute text.



10
11
12
# File 'lib/crazy_harry/base.rb', line 10

def text
  @text
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/crazy_harry/base.rb', line 17

def to_s
  self.fragment.to_s.squeeze(' ').strip
end