Sha256: c0bf23c160b0c1a58aefeb4218d8d2b821e77a6a1ffbd89b2a43541f208df4fe

Contents?: true

Size: 718 Bytes

Versions: 7

Compression:

Stored size: 718 Bytes

Contents

module ApipieBindings

  class Param

    attr_reader :name, :params, :expected_type, :description, :validator

    def initialize(param)
      param = ApipieBindings::IndifferentHash.new(param)
      @name = param[:name]
      params = param[:params] || []
      @params = params.map { |p| ApipieBindings::Param.new(p) }
      @expected_type = param[:expected_type].to_sym
      @description = param[:description].gsub(/<\/?[^>]+?>/, "")
      @required = param[:required]
      @validator = param[:validator]
    end

    def required?
      @required
    end

    def to_s
      "<Param #{ required? ? '*' : '' }#{@name} (#{@expected_type.to_s.capitalize})>"
    end

    def inspect
      to_s
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
apipie-bindings-0.0.9 lib/apipie_bindings/param.rb
apipie-bindings-0.0.8 lib/apipie_bindings/param.rb
apipie-bindings-0.0.7 lib/apipie_bindings/param.rb
apipie-bindings-0.0.6 lib/apipie_bindings/param.rb
apipie-bindings-0.0.5 lib/apipie_bindings/param.rb
apipie-bindings-0.0.4 lib/apipie_bindings/param.rb
apipie-bindings-0.0.3 lib/apipie_bindings/param.rb