Sha256: 55919b7e058a609e003cd1820d412652f399cc2ea1fad9233df9e2daed8020eb

Contents?: true

Size: 932 Bytes

Versions: 6

Compression:

Stored size: 932 Bytes

Contents

require_relative 'literal_asis'
require_relative 'composite_o_expression'

module Zenlish
  module Inflect
    class Concatenation < CompositeOExpression

      def initialize(argument1, argument2)
        super([validated_argument(argument1), validated_argument(argument2)])
      end

      def generate(headings, lexeme, values)
        part1 = children[0].generate(headings, lexeme, values)
        part2 = children[-1].generate(headings, lexeme, values)

        part1 + part2
      end

      private

      def validated_argument(anArgument)
        arg = nil
        if anArgument.kind_of?(String)
          arg = LiteralAsIs.new(anArgument)
        elsif anArgument.kind_of?(OutputExpression)
          arg = anArgument
        else
          err_msg = "Unexpected type of argument #{anArgument.inspect}."
          raise StandardError, err_msg
        end

        arg
      end
    end # class
  end # module
end # module

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zenlish-0.2.05 lib/zenlish/inflect/concatenation.rb
zenlish-0.2.04 lib/zenlish/inflect/concatenation.rb
zenlish-0.2.03 lib/zenlish/inflect/concatenation.rb
zenlish-0.2.02 lib/zenlish/inflect/concatenation.rb
zenlish-0.2.01 lib/zenlish/inflect/concatenation.rb
zenlish-0.2.00 lib/zenlish/inflect/concatenation.rb