Class: Dtmcli::Msg

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

Constant Summary collapse

TRANS_TYPE =
'msg'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dtm_url) ⇒ Msg

Returns a new instance of Msg.



8
9
10
11
12
13
# File 'lib/dtmcli/msg.rb', line 8

def initialize(dtm_url)
  @dtm_url = dtm_url
  @dtm = Dtm.new(dtm_url)
  @steps = []
  @query_prepared = ''
end

Instance Attribute Details

#dtmObject (readonly)

Returns the value of attribute dtm.



4
5
6
# File 'lib/dtmcli/msg.rb', line 4

def dtm
  @dtm
end

#dtm_urlObject (readonly)

Returns the value of attribute dtm_url.



4
5
6
# File 'lib/dtmcli/msg.rb', line 4

def dtm_url
  @dtm_url
end

#gidObject

Returns the value of attribute gid.



3
4
5
# File 'lib/dtmcli/msg.rb', line 3

def gid
  @gid
end

#query_preparedObject

Returns the value of attribute query_prepared.



3
4
5
# File 'lib/dtmcli/msg.rb', line 3

def query_prepared
  @query_prepared
end

#stepsObject

Returns the value of attribute steps.



3
4
5
# File 'lib/dtmcli/msg.rb', line 3

def steps
  @steps
end

Instance Method Details

#add(action, post_data) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/dtmcli/msg.rb', line 19

def add(action, post_data)
  step = {
    action: action,
    data:   post_data.to_json,
  }
  @steps << step
end

#gen_gidObject



15
16
17
# File 'lib/dtmcli/msg.rb', line 15

def gen_gid
  @gid = IdGenerator.gen_gid(dtm_url)
end

#prepare(p_url) ⇒ Object



27
28
29
30
# File 'lib/dtmcli/msg.rb', line 27

def prepare(p_url)
  @query_prepared = p_url if !p_url.nil?
  dtm.prepare(wrap_tbody)
end

#submitObject



32
33
34
# File 'lib/dtmcli/msg.rb', line 32

def submit
  dtm.submit(wrap_tbody)
end

#wrap_tbodyObject



36
37
38
39
40
41
42
43
# File 'lib/dtmcli/msg.rb', line 36

def wrap_tbody
  {
    gid:            gid,
    trans_type:     TRANS_TYPE,
    steps:          steps,
    query_prepared: query_prepared
  }
end