Class: StarkBank::Utils::Resource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ Resource

Returns a new instance of Resource.



7
8
9
# File 'lib/utils/resource.rb', line 7

def initialize(id = nil)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/utils/resource.rb', line 6

def id
  @id
end

Instance Method Details

#inspectObject



21
22
23
# File 'lib/utils/resource.rb', line 21

def inspect
  "#{class_name}[#{@id}]"
end

#to_sObject



11
12
13
14
15
16
17
18
19
# File 'lib/utils/resource.rb', line 11

def to_s
  string_vars = []
  instance_variables.each do |key|
    value = instance_variable_get(key).to_s.lines.map(&:chomp).join("\n  ")
    string_vars << "#{key[1..-1]}: #{value}"
  end
  fields = string_vars.join(",\n  ")
  "#{class_name}(\n  #{fields}\n)"
end