Class: Reportinator::StringFunction
- Defined in:
- lib/reportinator/functions/string.rb
Direct Known Subclasses
AdditionStringFunction, ConstantStringFunction, DateStringFunction, JoinStringFunction, LogicalStringFunction, NumberStringFunction, RangeStringFunction, SymbolStringFunction, VariableStringFunction
Constant Summary collapse
- PREFIXES =
[]
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Function
parse, #parse_and_execute_value, #parse_value, #prefixes
Methods inherited from Base
config, #config, logger, #logger
Methods included from Helpers
#merge_hash, #merge_hash!, #symbolize_attributes
Class Method Details
.accepts?(input) ⇒ Boolean
8 9 10 11 12 13 14 15 |
# File 'lib/reportinator/functions/string.rb', line 8 def self.accepts? input return false unless input.instance_of? String return false if self::PREFIXES.empty? self::PREFIXES.each do |prefix| return true if input.start_with? prefix end false end |
Instance Method Details
#get ⇒ Object
17 18 19 20 21 |
# File 'lib/reportinator/functions/string.rb', line 17 def get raise "Function missing output!" unless respond_to? :output set_attributes output end |
#set_attributes ⇒ Object
23 24 25 26 27 |
# File 'lib/reportinator/functions/string.rb', line 23 def set_attributes prefix = get_prefix(element) self.prefix = prefix self.body = element.sub(prefix, "") end |