Class: Mbti::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/mbti/type.rb,
lib/mbti/type/istj.rb,
lib/mbti/type/esfp.rb,
lib/mbti/type/intp.rb,
lib/mbti/type/isfp.rb,
lib/mbti/type/isfj.rb,
lib/mbti/type/intj.rb,
lib/mbti/type/entj.rb,
lib/mbti/type/esfj.rb,
lib/mbti/type/entp.rb,
lib/mbti/type/enfj.rb,
lib/mbti/type/estp.rb,
lib/mbti/type/enfp.rb,
lib/mbti/type/infj.rb,
lib/mbti/type/estj.rb,
lib/mbti/type/istp.rb,
lib/mbti/type/infp.rb

Overview

An instance of this class will provide proper representation of a single Myers-Briggs personality type.

Direct Known Subclasses

Enfj, Enfp, Entj, Entp, Esfj, Esfp, Estj, Estp, Infj, Infp, Intj, Intp, Isfj, Isfp, Istj, Istp

Defined Under Namespace

Classes: Enfj, Enfp, Entj, Entp, Esfj, Esfp, Estj, Estp, Infj, Infp, Intj, Intp, Isfj, Isfp, Istj, Istp

Instance Attribute Summary collapse

Type Trait Detection Methods collapse

Instance Method Summary collapse

Constructor Details

#initialize(attitude, perceiving_function, judging_function, lifestyle) ⇒ Mbti::Type

Creates an instance of the Type class

Parameters:

  • attitude (Numeric, Symbol)

    The scale representing the attitude trait of the type.

  • perceiving_function (Numeric, Symbol)

    The scale representing the perceiving function trait of the type.

  • judging_function (Numeric, Symbol)

    The scale representing the judging function trait of the type.

  • lifestyle (Numeric, Symbol)

    The scale representing the lifestyle trait of the type.

Raises:

  • (StandardError)

    when the type cannot be properly created


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/mbti/type.rb', line 30

def initialize(attitude, perceiving_function, judging_function, lifestyle)
  case attitude
    when(attitude.is_a? Numeric)
      @attitude = attitude
    when(attitude == :introvert)
      @attitude = 1
    when(attitude == :i)
      @attitude = 1
    when(attitude == :extrovert)
      @attitude = -1
    when(attitude == :e)
      @attitude = -1
    else
      raise StandardError, "Improper Attitude Trait Parameter: #{attitude}"
  end

  case perceiving_function
    when(perceiving_function.is_a? Numeric)
      @perceiving_function = perceiving_function
    when(perceiving_function == :intuitive)
      @perceiving_function = -1
    when(perceiving_function == :n)
      @perceiving_function = -1
    when(perceiving_function == :observant)
      @perceiving_function = 1
    when(perceiving_function == :observing)
      @perceiving_function = 1
    when(perceiving_function == :s)
      @perceiving_function = 1
    else
      raise StandardError, "Improper Perceiving Function Trait Parameter: #{perceiving_function}"
  end

  case judging_function
    when(judging_function.is_a? Numeric)
      @judging_function = judging_function
    when(judging_function == :thinking)
      @judging_function = -1
    when(judging_function == :t)
      @judging_function = -1
    when(judging_function == :feeling)
      @judging_function = 1
    when(judging_function == :f)
      @judging_function = 1
    else
      raise StandardError, "Improper Judging Function Trait Parameter: #{judging_function}"
  end

  case lifestyle
    when(lifestyle.is_a? Numeric)
      @lifestyle = lifestyle
    when(lifestyle == :judging)
      @lifestyle = -1
    when(lifestyle == :j)
      @lifestyle = -1
    when(lifestyle == :perceiving)
      @lifestyle = 1
    when(lifestyle == :p)
      @lifestyle = 1
    else
      raise StandardError, "Improper Lifestyle Trait Parameter: #{lifestyle}"
  end
  
  self
end

Instance Attribute Details

#attitudeInteger

Returns representation of the attitude trait of the type

Returns:

  • (Integer)

    representation of the attitude trait of the type


18
19
20
# File 'lib/mbti/type.rb', line 18

def attitude
  @attitude
end

#judging_functionInteger

Returns representation of the judguing function trait of the type

Returns:

  • (Integer)

    representation of the judguing function trait of the type


18
# File 'lib/mbti/type.rb', line 18

attr_accessor :attitude, :perceiving_function, :judging_function, :lifestyle

#lifestyleInteger

Returns representation of the lifestyle trait of the type

Returns:

  • (Integer)

    representation of the lifestyle trait of the type


18
# File 'lib/mbti/type.rb', line 18

attr_accessor :attitude, :perceiving_function, :judging_function, :lifestyle

#perceiving_functionInteger

Returns representation of the perceiving function trait of the type

Returns:

  • (Integer)

    representation of the perceiving function trait of the type


18
# File 'lib/mbti/type.rb', line 18

attr_accessor :attitude, :perceiving_function, :judging_function, :lifestyle

Instance Method Details

#extraverted?boolean

Checks if the type will have the extraverted trait.

Returns:

  • (boolean)

    if the trait is extraverted


101
102
103
104
105
106
107
# File 'lib/mbti/type.rb', line 101

def extraverted?
  if @attitude < 0
    true
  else
    false
  end
end

#feeling?boolean

Checks if the type will have the feeling trait.

Returns:

  • (boolean)

    if the trait is feeling


156
157
158
159
160
161
162
# File 'lib/mbti/type.rb', line 156

def feeling?
  if @judging_function > 0
    true
  else
    false
  end
end

#introverted?boolean

Checks if the type will have the introverted trait.

Returns:

  • (boolean)

    if the trait is introverted


112
113
114
115
116
117
118
# File 'lib/mbti/type.rb', line 112

def introverted?
  if @attitude > 0
    true
  else
    false
  end
end

#intuitive?boolean

Checks if the type will have the intuitive trait.

Returns:

  • (boolean)

    if the trait is intuitive


123
124
125
126
127
128
129
# File 'lib/mbti/type.rb', line 123

def intuitive?
  if @perceiving_function < 0
    true
  else
    false
  end
end

#judging?boolean

Checks if the type will have the judging trait.

Returns:

  • (boolean)

    if the trait is judging


167
168
169
170
171
172
173
# File 'lib/mbti/type.rb', line 167

def judging?
  if @lifestyle < 0
    true
  else
    false
  end
end

#observant?boolean

Checks if the type will have the observant trait.

Returns:

  • (boolean)

    if the trait is observant


134
135
136
137
138
139
140
# File 'lib/mbti/type.rb', line 134

def observant?
  if @perceiving_function > 0
    true
  else
    false
  end
end

#perceiving?boolean

Checks if the type will have the perceiving trait.

Returns:

  • (boolean)

    if the trait is perceiving


178
179
180
181
182
183
184
# File 'lib/mbti/type.rb', line 178

def perceiving?
  if @lifestyle > 0
    true
  else
    false
  end
end

#thinking?boolean

Checks if the type will have the thinking trait.

Returns:

  • (boolean)

    if the trait is thinking


145
146
147
148
149
150
151
# File 'lib/mbti/type.rb', line 145

def thinking?
  if @judging_function < 0
    true
  else
    false
  end
end