Class: MethodParam
- Inherits:
-
Object
- Object
- MethodParam
- Defined in:
- lib/phari_doc_gen/methodParam.rb
Overview
THE BEER-WARE LICENSEā (Revision 42): <[email protected]> wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Luiz Philippe.
Instance Attribute Summary collapse
-
#childAttributes ⇒ Object
Returns the value of attribute childAttributes.
-
#example ⇒ Object
Returns the value of attribute example.
-
#isChild ⇒ Object
Returns the value of attribute isChild.
-
#isCollection ⇒ Object
Returns the value of attribute isCollection.
-
#isObject ⇒ Object
Returns the value of attribute isObject.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notNull ⇒ Object
Returns the value of attribute notNull.
-
#serial ⇒ Object
Returns the value of attribute serial.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #addField(attribute) ⇒ Object
- #dump ⇒ Object
-
#initialize(name = "", type = "", notNull = true, isObject = false, isCollection = false, isChild = false, example = nil) ⇒ MethodParam
constructor
A new instance of MethodParam.
- #serialize ⇒ Object
- #setContent(attribute) ⇒ Object
Constructor Details
#initialize(name = "", type = "", notNull = true, isObject = false, isCollection = false, isChild = false, example = nil) ⇒ MethodParam
Returns a new instance of MethodParam.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/phari_doc_gen/methodParam.rb', line 11 def initialize(name = "", type = "", notNull = true, isObject = false, isCollection = false, isChild = false, example = nil) @name = name @type = type @notNull = notNull @isObject = isObject @isCollection = isCollection @isChild = isChild @example = example @childAttributes = {} if (@isObject || @isCollection) end |
Instance Attribute Details
#childAttributes ⇒ Object
Returns the value of attribute childAttributes.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def childAttributes @childAttributes end |
#example ⇒ Object
Returns the value of attribute example.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def example @example end |
#isChild ⇒ Object
Returns the value of attribute isChild.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def isChild @isChild end |
#isCollection ⇒ Object
Returns the value of attribute isCollection.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def isCollection @isCollection end |
#isObject ⇒ Object
Returns the value of attribute isObject.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def isObject @isObject end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def name @name end |
#notNull ⇒ Object
Returns the value of attribute notNull.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def notNull @notNull end |
#serial ⇒ Object
Returns the value of attribute serial.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def serial @serial end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/phari_doc_gen/methodParam.rb', line 9 def type @type end |
Instance Method Details
#addField(attribute) ⇒ Object
22 23 24 25 |
# File 'lib/phari_doc_gen/methodParam.rb', line 22 def addField attribute raise ArgumentError, "Cannot add field to no object param" unless @isObject @childAttributes["#{attribute.name}"] = attribute end |
#dump ⇒ Object
58 59 60 |
# File 'lib/phari_doc_gen/methodParam.rb', line 58 def dump puts self.serialize end |
#serialize ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/phari_doc_gen/methodParam.rb', line 32 def serialize if @type == 'nil' serialized = "Null" elsif @isObject serialized = "#{@name}: {<br><ul>" @childAttributes.each do |attribute| serialized = serialized + "<li>#{attribute[1].serialize}</li>" end serialized = serialized + "</ul>}" elsif @isCollection if @childAttributes['content'].nil? serialized = "#{@name}: [<br><ul><li>Null</li><li>...</li></ul>" else # puts "child attributes: #{@childAttributes['content'].type}" serialized = "#{@name}: [<br><ul><li>#{@childAttributes['content'].serialize},</li><li>...</li>]</ul>" end else unless @example.nil? serialized = "#{@name}: #{@example}" else serialized = "#{@name}: #{@type}" end end serialized end |
#setContent(attribute) ⇒ Object
27 28 29 30 |
# File 'lib/phari_doc_gen/methodParam.rb', line 27 def setContent attribute raise ArgumentError, "Cannot set content of no array param" unless @isCollection @childAttributes["content"] = attribute end |