Class: Diograph::Diory

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Diory

Returns a new instance of Diory.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/diograph/diory.rb', line 8

def initialize(args={})
  @diory_id = args[:diory_id] || args[:ID]
  @name = args[:name]
  @diory_type = args[:diory_type]
  @date = args[:date]
  @address = args[:address]
  @background = args[:background]
  @latitude = args[:latitude]
  @longitude = args[:longitude]
  @created = args[:created]
  @modified = args[:modified]

  @room = args[:room]
  @room.diories << self if @room

  @connections = args[:connections] || []
  @connected_diories = args[:connected_diories] || []
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def address
  @address
end

#backgroundObject (readonly)

Returns the value of attribute background.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def background
  @background
end

#connected_dioriesObject

Returns the value of attribute connected_diories.



6
7
8
# File 'lib/diograph/diory.rb', line 6

def connected_diories
  @connected_diories
end

#connectionsObject (readonly)

Returns the value of attribute connections.



6
7
8
# File 'lib/diograph/diory.rb', line 6

def connections
  @connections
end

#createdObject (readonly)

Returns the value of attribute created.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def created
  @created
end

#dateObject (readonly)

Returns the value of attribute date.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def date
  @date
end

#diory_idObject (readonly)

Returns the value of attribute diory_id.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def diory_id
  @diory_id
end

#diory_typeObject (readonly)

Returns the value of attribute diory_type.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def diory_type
  @diory_type
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def longitude
  @longitude
end

#modifiedObject (readonly)

Returns the value of attribute modified.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def modified
  @modified
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/diograph/diory.rb', line 5

def name
  @name
end

#roomObject (readonly)

Returns the value of attribute room.



6
7
8
# File 'lib/diograph/diory.rb', line 6

def room
  @room
end

Instance Method Details

#connect_to(to_diory) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/diograph/diory.rb', line 27

def connect_to(to_diory)
  connection = Connection.new(from_diory: self, to_diory: to_diory)
  @connections << connection
  @connected_diories << to_diory
  to_diory.connections << connection
  to_diory.connected_diories << self
end