Class: Kamome::Models::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/kamome/models/address.rb

Constant Summary collapse

STATE_NOT_CHANGE =
0
STATE_UPDATE =
1
STATE_DELETE =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Address

Returns a new instance of Address.



65
66
67
68
69
# File 'lib/kamome/models/address.rb', line 65

def initialize(params = {})
  params.each do |key, value|
    public_send("#{key}=", value)
  end
end

Instance Attribute Details

#ambiguous_townBoolean

一町域が二以上の郵便番号で表される場合 true genre: :general のみ

Returns:

  • (Boolean)


58
59
60
# File 'lib/kamome/models/address.rb', line 58

def ambiguous_town
  @ambiguous_town
end

#cityString

市区町村

Returns:

  • (String)


24
25
26
# File 'lib/kamome/models/address.rb', line 24

def city
  @city
end

#codeString

全国地方公共団体コード

Returns:

  • (String)


9
10
11
# File 'lib/kamome/models/address.rb', line 9

def code
  @code
end

#company_nameString

企業名/団体名 等

Returns:

  • (String)


39
40
41
# File 'lib/kamome/models/address.rb', line 39

def company_name
  @company_name
end

#post_office_boxString

私書箱名

Returns:

  • (String)


44
45
46
# File 'lib/kamome/models/address.rb', line 44

def post_office_box
  @post_office_box
end

#prefectureString

都道府県名

Returns:

  • (String)


19
20
21
# File 'lib/kamome/models/address.rb', line 19

def prefecture
  @prefecture
end

#stateInteger

状態

0: 変更なし
1: 変更あり
2: 削除

Returns:

  • (Integer)


52
53
54
# File 'lib/kamome/models/address.rb', line 52

def state
  @state
end

#streetString

番地, 建物等

Returns:

  • (String)


34
35
36
# File 'lib/kamome/models/address.rb', line 34

def street
  @street
end

#townString

町域

Returns:

  • (String)


29
30
31
# File 'lib/kamome/models/address.rb', line 29

def town
  @town
end

#zipcodeString

郵便番号(7桁)

Returns:

  • (String)


14
15
16
# File 'lib/kamome/models/address.rb', line 14

def zipcode
  @zipcode
end

Instance Method Details

#attributesHash

Returns model attributes.

Returns:

  • (Hash)

    model attributes



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/kamome/models/address.rb', line 72

def attributes
  {
    code: code,
    zipcode: zipcode,
    prefecture: prefecture,
    city: city,
    town: town,
    street: street,
    company_name: company_name,
    post_office_box: post_office_box,
    state: state,
    ambiguous_town: ambiguous_town
  }
end

#change?Boolean

Returns true when state is 1 or 2

Returns:

  • (Boolean)


89
90
91
# File 'lib/kamome/models/address.rb', line 89

def change?
  updated? || deleted?
end

#delete?Boolean

Returns true when state is 2

Returns:

  • (Boolean)


101
102
103
# File 'lib/kamome/models/address.rb', line 101

def delete?
  state == STATE_DELETE
end

#update?Boolean

Returns true when state is 1

Returns:

  • (Boolean)


95
96
97
# File 'lib/kamome/models/address.rb', line 95

def update?
  state == STATE_UPDATE
end