Class: Sinatra::Rabbit::Param
- Inherits:
-
Object
- Object
- Sinatra::Rabbit::Param
- Defined in:
- lib/sinatra/rabbit/param.rb
Instance Attribute Summary (collapse)
-
- (Object) description
readonly
Returns the value of attribute description.
-
- (Object) klass
readonly
Returns the value of attribute klass.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) required
readonly
Returns the value of attribute required.
-
- (Object) values
readonly
Returns the value of attribute values.
Instance Method Summary (collapse)
- - (Boolean) enum?
-
- (Param) initialize(*args)
constructor
A new instance of Param.
- - (Boolean) number?
- - (Boolean) optional?
- - (Boolean) required?
- - (Boolean) string?
- - (Object) to_s
Constructor Details
- (Param) initialize(*args)
A new instance of Param
22 23 24 25 26 27 28 |
# File 'lib/sinatra/rabbit/param.rb', line 22 def initialize(*args) args.reverse! @name, @klass = args.pop, args.pop raise "DSL: You need to specify the name and param type (#{@name})" unless @name or @klass parse_params!(args) @description ||= "Description not available" end |
Instance Attribute Details
- (Object) description (readonly)
Returns the value of attribute description
20 21 22 |
# File 'lib/sinatra/rabbit/param.rb', line 20 def description @description end |
- (Object) klass (readonly)
Returns the value of attribute klass
20 21 22 |
# File 'lib/sinatra/rabbit/param.rb', line 20 def klass @klass end |
- (Object) name (readonly)
Returns the value of attribute name
20 21 22 |
# File 'lib/sinatra/rabbit/param.rb', line 20 def name @name end |
- (Object) required (readonly)
Returns the value of attribute required
20 21 22 |
# File 'lib/sinatra/rabbit/param.rb', line 20 def required @required end |
- (Object) values (readonly)
Returns the value of attribute values
20 21 22 |
# File 'lib/sinatra/rabbit/param.rb', line 20 def values @values end |
Instance Method Details
- (Boolean) enum?
32 |
# File 'lib/sinatra/rabbit/param.rb', line 32 def enum?; !@values.nil?; end |
- (Boolean) number?
33 |
# File 'lib/sinatra/rabbit/param.rb', line 33 def number?; [:integer, :float, :number].include?(@klass); end |
- (Boolean) optional?
31 |
# File 'lib/sinatra/rabbit/param.rb', line 31 def optional?; !required?; end |
- (Boolean) required?
30 |
# File 'lib/sinatra/rabbit/param.rb', line 30 def required?; @required == true; end |
- (Boolean) string?
34 |
# File 'lib/sinatra/rabbit/param.rb', line 34 def string?; @klass == :string; end |
- (Object) to_s
36 37 38 |
# File 'lib/sinatra/rabbit/param.rb', line 36 def to_s "#{name}:#{klass}:#{required? ? 'required' : 'optional'}" end |