Class: Thot::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/thot/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, rule:) ⇒ Processor

Returns a new instance of Processor.



6
7
8
9
# File 'lib/thot/processor.rb', line 6

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

Instance Attribute Details

#ruleObject (readonly)

Returns the value of attribute rule.



4
5
6
# File 'lib/thot/processor.rb', line 4

def rule
  @rule
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/thot/processor.rb', line 3

def value
  @value
end

Instance Method Details

#resultObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/thot/processor.rb', line 11

def result
    if @value.nil? then
        result = (@rule[:default])? @rule[:default] : ''
    else
        result = @value
        @rule[:filters].each do |filter|
            result = result.send filter.to_sym if result.respond_to? filter.to_sym
        end
    end
    return result
end