Class: HakumiComponents::Documentation::Component
- Inherits:
-
Object
- Object
- HakumiComponents::Documentation::Component
- Extended by:
- T::Sig
- Defined in:
- lib/hakumi_components/documentation/models.rb
Instance Attribute Summary collapse
-
#api_sections ⇒ Object
readonly
Returns the value of attribute api_sections.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#when_not_to_use ⇒ Object
readonly
Returns the value of attribute when_not_to_use.
-
#when_to_use ⇒ Object
readonly
Returns the value of attribute when_to_use.
Instance Method Summary collapse
-
#initialize(name:, description: nil, category: nil, when_to_use: [], when_not_to_use: [], examples: [], api_sections: []) ⇒ Component
constructor
A new instance of Component.
- #to_h ⇒ Object
- #with_examples(examples) ⇒ Object
Constructor Details
#initialize(name:, description: nil, category: nil, when_to_use: [], when_not_to_use: [], examples: [], api_sections: []) ⇒ Component
Returns a new instance of Component.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/hakumi_components/documentation/models.rb', line 224 def initialize( name:, description: nil, category: nil, when_to_use: [], when_not_to_use: [], examples: [], api_sections: [] ) @name = name @description = description @category = category @when_to_use = when_to_use @when_not_to_use = when_not_to_use @examples = examples @api_sections = api_sections end |
Instance Attribute Details
#api_sections ⇒ Object (readonly)
Returns the value of attribute api_sections.
261 262 263 |
# File 'lib/hakumi_components/documentation/models.rb', line 261 def api_sections @api_sections end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
249 250 251 |
# File 'lib/hakumi_components/documentation/models.rb', line 249 def category @category end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
246 247 248 |
# File 'lib/hakumi_components/documentation/models.rb', line 246 def description @description end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
258 259 260 |
# File 'lib/hakumi_components/documentation/models.rb', line 258 def examples @examples end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
243 244 245 |
# File 'lib/hakumi_components/documentation/models.rb', line 243 def name @name end |
#when_not_to_use ⇒ Object (readonly)
Returns the value of attribute when_not_to_use.
255 256 257 |
# File 'lib/hakumi_components/documentation/models.rb', line 255 def when_not_to_use @when_not_to_use end |
#when_to_use ⇒ Object (readonly)
Returns the value of attribute when_to_use.
252 253 254 |
# File 'lib/hakumi_components/documentation/models.rb', line 252 def when_to_use @when_to_use end |
Instance Method Details
#to_h ⇒ Object
277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/hakumi_components/documentation/models.rb', line 277 def to_h { "name" => @name, "description" => @description, "category" => @category, "when_to_use" => @when_to_use, "when_not_to_use" => @when_not_to_use, "examples" => @examples.map(&:to_h), "api_sections" => @api_sections.map(&:to_h) } end |
#with_examples(examples) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/hakumi_components/documentation/models.rb', line 264 def with_examples(examples) self.class.new( name: @name, description: @description, category: @category, when_to_use: @when_to_use, when_not_to_use: @when_not_to_use, examples: examples, api_sections: @api_sections ) end |