Sha256: e9ccc051b48a83da6c5b3c80ab2421b0752237b3f52ef4c9ba5cd266e5932cb4

Contents?: true

Size: 532 Bytes

Versions: 6

Compression:

Stored size: 532 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,1] = e[0,1].upcase; e }.join
      end

    end # Type
  end # Ast
end # WebIDL

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
webidl-0.1.0 lib/webidl/ast/type.rb
webidl-0.0.9 lib/webidl/ast/type.rb
webidl-0.0.8 lib/webidl/ast/type.rb
webidl-0.0.7 lib/webidl/ast/type.rb
webidl-0.0.6 lib/webidl/ast/type.rb
webidl-0.0.5 lib/webidl/ast/type.rb