Class: Relevance::Tarantula::Transform

Inherits:
Object
  • Object
show all
Defined in:
lib/relevance/tarantula/transform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to) ⇒ Transform

Returns a new instance of Transform.



6
7
8
9
# File 'lib/relevance/tarantula/transform.rb', line 6

def initialize(from, to)
  @from = from
  @to = to
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



5
6
7
# File 'lib/relevance/tarantula/transform.rb', line 5

def from
  @from
end

#toObject

Returns the value of attribute to.



5
6
7
# File 'lib/relevance/tarantula/transform.rb', line 5

def to
  @to
end

Instance Method Details

#[](string) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/relevance/tarantula/transform.rb', line 10

def [](string)
  case to
  when Proc
    string.gsub(from, &to)
  else
    string.gsub(from, to)
  end
end