Sha256: 8f4d82580d676d421c291c68e9afc7834aa76ebd2fe45b95a20722148d716c62

Contents?: true

Size: 528 Bytes

Versions: 2

Compression:

Stored size: 528 Bytes

Contents

module WebIDL
  module Ast
    class Type < Node

      attr_reader :name

      def initialize(parent, name, opts = {})
        super(parent)

        @name     = camel_case_type(name.strip).to_sym
        @nullable = !!opts[:nullable]
      end

      def nullable?
        @nullable
      end

      def array!
        @name = "#{@name}Array".to_sym
      end

      private

      def camel_case_type(name)
        name.split(/[_ ]/).map { |e| e[0] = e[0].upcase; e }.join
      end

    end # Type
  end # Ast
end # WebIDL

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webidl-0.0.4 lib/webidl/ast/type.rb
webidl-0.0.3 lib/webidl/ast/type.rb