Class: Crystel

Inherits:
Object show all
Defined in:
lib/crystel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = "") ⇒ Crystel

Returns a new instance of Crystel.



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

def initialize(value="")
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#blank_inputObject



10
11
12
# File 'lib/crystel.rb', line 10

def blank_input
  @value = gets.chomp
end

#contains?(smaller_thing) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/crystel.rb', line 23

def contains?(smaller_thing)
  @value.include? smaller_thing
end

#from_prompt(user_input) ⇒ Object



13
14
15
16
# File 'lib/crystel.rb', line 13

def from_prompt(user_input)
  puts user_input
  @value = gets.chomp
end

#in(bigger_thing) ⇒ Object



20
21
22
# File 'lib/crystel.rb', line 20

def in(bigger_thing)
  bigger_thing.include? @value
end

#isin?(bigger_thing) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/crystel.rb', line 17

def isin?(bigger_thing)
  bigger_thing.value.include? @value
end


7
8
9
# File 'lib/crystel.rb', line 7

def print
  @value
end

#s(num1, num2 = " ") ⇒ Object



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

def s(num1, num2=" ")
  if num2 == " "
    num2 = @value.length
  end
  @value[num1...num2]
end

#s!(num1, num2 = " ") ⇒ Object



32
33
34
35
36
37
# File 'lib/crystel.rb', line 32

def s!(num1, num2=" ")
  if num2 == " "
    num2 = @value.length
  end
  self.replace(@value[num1...num2])
end