Method: Weechat::Utilities.apply_transformation

Defined in:
lib/weechat/utilities.rb

.apply_transformation(property, value, transformations) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/weechat/utilities.rb', line 40

def self.apply_transformation(property, value, transformations)
  transformation = transformations.find {|properties, transformations|
    properties.any? {|prop|
      case prop
      when Regexp
        prop =~ property.to_s
      when String, Symbol
        prop.to_sym == property.to_sym
      else
        false
      end
    }
  }

  if transformation
    transformation[1].call(value)
  else
    value
  end
end