Class: Aston::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/aston.rb

Overview

Wrapper for content

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (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

#sizeObject



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_sObject



72
73
74
# File 'lib/aston.rb', line 72

def to_s
  @data.map(&:to_s).join("\n")
end