Sha256: 12b2b4cf9d5732e5045fe150f9cde490e7e270332587bdc198ccebf1d36951b6

Contents?: true

Size: 503 Bytes

Versions: 4

Compression:

Stored size: 503 Bytes

Contents

module SexpThing

  class Args < Base

    def [](index)
      args[index]
    end

    def count
      args.count
    end

    private

    def args
      arg_list + optional_args_list
    end

    def arg_list
      return (sexp[1] ? [Arg.new(sexp[1])] : []) if sexp[0] == :params
      (sexp[0] == :paren ? sexp[1][1] : sexp[1]).map{|a| Arg.new(a) }
    end

    def optional_args_list
      as = (sexp[0] == :paren ? sexp[1][2] : sexp[2])
      as ? as.map{|a| Arg.new(a) } : []
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sexp_info-0.0.4 lib/sexp_info/sexp_thing/args.rb
sexp_info-0.0.3 lib/sexp_info/sexp_thing/args.rb
sexp_info-0.0.2 lib/sexp_info/sexp_thing/args.rb
sexp_info-0.0.1 lib/sexp_info/sexp_thing/args.rb