-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_005.rb
More file actions
51 lines (39 loc) · 1.13 KB
/
ex_005.rb
File metadata and controls
51 lines (39 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/ruby
# Pangram
# Determine if a sentence is a pangram.
# A pangram is a sentence using every letter of the alphabet
# at least once. The best known English pangram is:
# "The quick brown fox jumps over the lazy dog."
# The alphabet used consists of ASCII letters a to z,
# inclusive, and is case insensitive.
# Input will not contain non-ASCII symbols.
# https://exercism.io/tracks/ruby/exercises/pangram
# Run
# ruby [Script Name]
class Lexic
def initialize(*message)
(message.is_a? Array) ? @message = message.join : @message = message
end
def set(message)
@message = message.join if message.is_a? Array
end
def acronym()
@message.downcase!
aux = @message.split
aux.map! { |a| a.capitalize.chr}
@message = aux.join
end
def pangram()
characters = @message.downcase.split(//)
hash = {}
("a".."z").each{ |letter| hash[letter] = false }
for char in characters
hash[char] = true
end
return !hash.has_value?(false)
end
def get()
"#{@message}"
end
end
puts Lexic.new(gets).pangram