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.



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

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

Instance Attribute Details

#fromObject

Returns the value of attribute from.



2
3
4
# File 'lib/relevance/tarantula/transform.rb', line 2

def from
  @from
end

#toObject

Returns the value of attribute to.



2
3
4
# File 'lib/relevance/tarantula/transform.rb', line 2

def to
  @to
end

Instance Method Details

#[](string) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/relevance/tarantula/transform.rb', line 7

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