Sha256: d85f17e4c19fca68b1b4c4d2f43077d9d485d99782c60a934c2ee688220879fd

Contents?: true

Size: 709 Bytes

Versions: 13

Compression:

Stored size: 709 Bytes

Contents

module WebIDL
  module Ast
    class Type < Node

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

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

      def nullable?
        @nullable
      end

      def array?
        @array
      end

      def array=(bool)
        @array = bool
      end

      def nullable=(bool)
        @nullable = bool
      end

      def name
        (array? ? "#{@name}Array" : @name).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

13 entries across 13 versions & 1 rubygems

Version Path
webidl-0.2.2 lib/webidl/ast/type.rb
webidl-0.2.1 lib/webidl/ast/type.rb
webidl-0.1.10 lib/webidl/ast/type.rb
webidl-0.2.0 lib/webidl/ast/type.rb
webidl-0.1.9 lib/webidl/ast/type.rb
webidl-0.1.8 lib/webidl/ast/type.rb
webidl-0.1.7 lib/webidl/ast/type.rb
webidl-0.1.6 lib/webidl/ast/type.rb
webidl-0.1.5 lib/webidl/ast/type.rb
webidl-0.1.4 lib/webidl/ast/type.rb
webidl-0.1.3 lib/webidl/ast/type.rb
webidl-0.1.2 lib/webidl/ast/type.rb
webidl-0.1.1 lib/webidl/ast/type.rb