Class: Aston::Content
- Inherits:
-
Object
- Object
- Aston::Content
- Defined in:
- lib/aston.rb
Overview
Wrapper for content
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #<<(elem) ⇒ Object
- #==(other) ⇒ Object
- #[](index) ⇒ Object
-
#initialize(data = []) ⇒ Content
constructor
A new instance of Content.
- #size ⇒ Object
- #to_json(opts = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data = []) ⇒ Content
Returns a new instance of Content.
50 51 52 |
# File 'lib/aston.rb', line 50 def initialize(data = []) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
48 49 50 |
# File 'lib/aston.rb', line 48 def data @data end |
Instance Method Details
#<<(elem) ⇒ Object
54 55 56 |
# File 'lib/aston.rb', line 54 def <<(elem) @data << elem end |
#==(other) ⇒ Object
64 65 66 |
# File 'lib/aston.rb', line 64 def ==(other) other.is_a?(Content) && @data == other.data end |
#[](index) ⇒ Object
58 59 60 61 62 |
# File 'lib/aston.rb', line 58 def [](index) @data[index] rescue StandardError => e raise Error, e end |
#size ⇒ Object
68 69 70 |
# File 'lib/aston.rb', line 68 def size @data.size end |
#to_json(opts = nil) ⇒ Object
76 77 78 |
# File 'lib/aston.rb', line 76 def to_json(opts = nil) @data.to_json(opts) end |
#to_s ⇒ Object
72 73 74 |
# File 'lib/aston.rb', line 72 def to_s @data.map(&:to_s).join("\n") end |