Class: Aun::Message

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

Overview

Message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a, un, owner: :unknown, origin: :unknown, user_defined: false) ⇒ Message

Returns a new instance of Message.



6
7
8
# File 'lib/aun/message.rb', line 6

def initialize(a, un, owner: :unknown, origin: :unknown, user_defined: false)
  @a, @un, @owner, @origin, @user_defined = a, un, owner, origin, user_defined
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



5
6
7
# File 'lib/aun/message.rb', line 5

def a
  @a
end

#originObject (readonly)

Returns the value of attribute origin.



5
6
7
# File 'lib/aun/message.rb', line 5

def origin
  @origin
end

#ownerObject (readonly)

Returns the value of attribute owner.



5
6
7
# File 'lib/aun/message.rb', line 5

def owner
  @owner
end

#unObject (readonly)

Returns the value of attribute un.



5
6
7
# File 'lib/aun/message.rb', line 5

def un
  @un
end

#user_definedObject (readonly)

Returns the value of attribute user_defined.



5
6
7
# File 'lib/aun/message.rb', line 5

def user_defined
  @user_defined
end

Instance Method Details

#columnsArray(*String)

Columns

Returns:

  • (Array(*String))

    @a, @un, @owner, @origin, @user_defined



39
40
41
# File 'lib/aun/message.rb', line 39

def columns
  [@a, @un, @owner, @origin, @user_defined]
end

#inspectObject



33
34
35
# File 'lib/aun/message.rb', line 33

def inspect
  "阿:#{@a}\t吽:#{@un}\t発言者:#{@owner}\t原典:#{@origin},\tユーザー定義:#{user_defined}"
end

#owner_talkObject

talk (format ‘@owner 「@un」’) if @owner is empty, (format ‘@un’)



17
18
19
20
# File 'lib/aun/message.rb', line 17

def owner_talk
  return talk if unknown?(owner)
  "#{@owner}#{talk}"
end

#talkObject

talk (format ‘@un’)



11
12
13
# File 'lib/aun/message.rb', line 11

def talk
  @un
end

#talk_with_originObject

talk (format ‘@owner 「@un」 from [@origin]’) if @owner is empty and @origin is empty, (format ‘@un’) if @owner is empty and @origin is not empty, (format ‘@un’ from [@origin]) if @owner is not empty and @origin is empty, (format ‘@owner 「@un」’)



26
27
28
29
30
31
# File 'lib/aun/message.rb', line 26

def talk_with_origin
  ret = talk
  ret = "#{@owner}#{ret}" unless unknown?(@owner)
  ret = "#{ret} from [#{@origin}]" unless unknown?(@origin)
  ret
end