Class: AbideDevUtils::Ppt::CodeGen::Resource
- Inherits:
-
Object
- Object
- AbideDevUtils::Ppt::CodeGen::Resource
- Defined in:
- lib/abide_dev_utils/ppt/code_gen/resource.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, title, **attributes) ⇒ Resource
constructor
A new instance of Resource.
- #reference ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, title, **attributes) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 13 14 |
# File 'lib/abide_dev_utils/ppt/code_gen/resource.rb', line 9 def initialize(type, title, **attributes) validate_type_and_title(type, title) @type = type @title = title @attributes = attributes end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/abide_dev_utils/ppt/code_gen/resource.rb', line 7 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/abide_dev_utils/ppt/code_gen/resource.rb', line 7 def type @type end |
Instance Method Details
#reference ⇒ Object
16 17 18 |
# File 'lib/abide_dev_utils/ppt/code_gen/resource.rb', line 16 def reference "#{title.split('::').map(&:capitalize).join('::')}['#{title}']" end |
#to_s ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/abide_dev_utils/ppt/code_gen/resource.rb', line 20 def to_s return "#{type} { '#{title}': }" if @attributes.empty? str_array = ["#{type} { '#{title}':"] @attributes.each do |key, val| str_array << " #{pad_attribute(key)} => #{val}," end str_array << '}' str_array.join("\n") end |