Class: Redactor::Extract

Inherits:
Object
  • Object
show all
Defined in:
lib/redactor/extract.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule:, value:, start:, finish:) ⇒ Extract

Returns a new instance of Extract.



5
6
7
8
9
10
# File 'lib/redactor/extract.rb', line 5

def initialize(rule:, value:, start:, finish:)
  @rule = rule
  @value = value
  @start = start
  @finish = finish
end

Instance Attribute Details

#finishObject (readonly)

Returns the value of attribute finish.



3
4
5
# File 'lib/redactor/extract.rb', line 3

def finish
  @finish
end

#ruleObject (readonly)

Returns the value of attribute rule.



3
4
5
# File 'lib/redactor/extract.rb', line 3

def rule
  @rule
end

#startObject (readonly)

Returns the value of attribute start.



3
4
5
# File 'lib/redactor/extract.rb', line 3

def start
  @start
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/redactor/extract.rb', line 3

def value
  @value
end

Instance Method Details

#collides?(extract) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/redactor/extract.rb', line 16

def collides?(extract)
  [:start, :finish].any? do |m|
    extract.send(m).between?(start, finish)
  end
end

#reasonObject



12
13
14
# File 'lib/redactor/extract.rb', line 12

def reason
  rule.reason
end