Class: ChupaText::Attributes
- Inherits:
-
Struct
- Object
- Struct
- ChupaText::Attributes
- Includes:
- Enumerable
- Defined in:
- lib/chupa-text/attributes.rb
Overview
Attributes of data.
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#created_time ⇒ Object
Returns the value of attribute created_time.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#modified_time ⇒ Object
Returns the value of attribute modified_time.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Gets the value of attribute named
name
. -
#[]=(name, value) ⇒ Object
Sets
value
as the value of attribute namedname
. - #each {|name, value| ... } ⇒ Object
-
#initialize ⇒ Attributes
constructor
A new instance of Attributes.
- #inspect ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Attributes
Returns a new instance of Attributes.
26 27 28 29 |
# File 'lib/chupa-text/attributes.rb', line 26 def initialize super @extra_data = {} end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author
19 20 21 |
# File 'lib/chupa-text/attributes.rb', line 19 def @author end |
#created_time ⇒ Object
Returns the value of attribute created_time
19 20 21 |
# File 'lib/chupa-text/attributes.rb', line 19 def created_time @created_time end |
#encoding ⇒ Object
Returns the value of attribute encoding
19 20 21 |
# File 'lib/chupa-text/attributes.rb', line 19 def encoding @encoding end |
#modified_time ⇒ Object
Returns the value of attribute modified_time
19 20 21 |
# File 'lib/chupa-text/attributes.rb', line 19 def modified_time @modified_time end |
#title ⇒ Object
Returns the value of attribute title
19 20 21 |
# File 'lib/chupa-text/attributes.rb', line 19 def title @title end |
Instance Method Details
#[](name) ⇒ Object
Gets the value of attribute named name
.
57 58 59 60 61 62 63 64 |
# File 'lib/chupa-text/attributes.rb', line 57 def [](name) name = normalize_name(name) if members.include?(name) super else @extra_data[name] end end |
#[]=(name, value) ⇒ Object
Sets value
as the value of attribute named name
.
70 71 72 73 74 75 76 77 |
# File 'lib/chupa-text/attributes.rb', line 70 def []=(name, value) name = normalize_name(name) if members.include?(name) send("#{name}=", value) else @extra_data[name] = value end end |
#each {|name, value| ... } ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/chupa-text/attributes.rb', line 44 def each(&block) if block.nil? Enumerator.new(self, :each) else each_pair(&block) @extra_data.each_pair(&block) end end |
#inspect ⇒ Object
35 36 37 38 39 |
# File 'lib/chupa-text/attributes.rb', line 35 def inspect super.gsub(/>\z/) do " @extra_data=#{@extra_data.inspect}>" end end |
#to_h ⇒ Object
31 32 33 |
# File 'lib/chupa-text/attributes.rb', line 31 def to_h super.merge(@extra_data) end |