Sha256: 509f3221e32f4907e84f7a171cbb1ec8cf8f96b3ac482c0a93d0b0ccacb21656

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "food_truck"

module Eddy
  module Build

    def self.build_dt(e)
      fmt = determine_dt_format(e[:max])
      constructor = FoodTruck::Func.create({
        name: "initialize",
        body: <<~FUNC_BODY,
          @id = "#{e[:id]}"
          @name = "#{e[:name]}"
          @type = "DT"
          self.min = #{e[:min]}
          self.max = #{e[:max]}
          super(:#{fmt})
        FUNC_BODY
      }).render()
      data = {
        name: e[:name],
        description: e[:description],
        parent: "Eddy::Element::DT",
        modules: ["Eddy", "Elements"],
        body: constructor,
        file_prefix: "#{e[:id]}.",
      }
      c = FoodTruck::Class.create(data)
      c.generate(File.join(Eddy.root_dir, "build", "elements", "dt"))
      return nil
    end

    # @param int [Integer]
    # @return [Symbol]
    def self.determine_dt_format(int)
      case int
      when 6
        return :yymmdd
      when 8
        return :ccyymmdd
      else
        raise Eddy::Error, "unable to determine format for dt element"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eddy-0.1.0 lib/eddy/build/build_dt.rb