Class: Relevance::Tarantula::Transform
- Defined in:
- lib/relevance/tarantula/transform.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #[](string) ⇒ Object
-
#initialize(from, to) ⇒ Transform
constructor
A new instance of Transform.
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
#from ⇒ Object
Returns the value of attribute from.
2 3 4 |
# File 'lib/relevance/tarantula/transform.rb', line 2 def from @from end |
#to ⇒ Object
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 |