a1447ll_hpbd 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ab7df358534ecce20207723cf2a4110ad60bd32
4
- data.tar.gz: 469279e76b7f6209fc05a4d435dc4b4353528c6a
3
+ metadata.gz: 68abbb515b1556848dbd2d0d5f65da6606c0e849
4
+ data.tar.gz: b0ed1a285110c42d5b2b150275e11dff290e6a9e
5
5
  SHA512:
6
- metadata.gz: 463f41d9d27987308f453273541b14ae82daf53c0b312931f7fac93e802ad51138cd13e22a5903f893879cac9fc9b573c856d6270c54c3f2f92628cf3342eefd
7
- data.tar.gz: 496b7c34bb54bb862e170e217267836ff7cbf0bcac51edf8162e2e8893a8f17237c5864905046457ca31aabf087c0c561dd219369eadf120eaaa15e1e52dc509
6
+ metadata.gz: ac8144c4dbc959b7984a770a831c9be1ef7db209bd06e610d73da52422a5e3a12525ec52c0f8342c738f98508dc3898c1297e94a4020250c8fa78a7a6cb28b11
7
+ data.tar.gz: 1f90a7010de672410a86cc401df7863b9f09936f6c8288b9575f534ead66a8aee789a0b497686d1591dbf0e543ea89075e229218f6c8d3d1664f65a637a99596
@@ -1,15 +1,20 @@
1
1
  require "a1447ll_hpbd/version"
2
- require "a1447ll_hpbd/msg"
2
+ require "a1447ll_hpbd/message"
3
3
 
4
4
  module A1447llHpbd
5
- def self.show n
5
+ def self.run
6
+ print "In put a name: "
7
+ n = gets.chomp
6
8
  s = n.upcase.split(%r{\s*})
7
9
  name = ""
8
10
  for i in 0 .. s.length-2 do
9
11
  name = name + s[i] + "."
10
12
  end
11
- name = name + s[-1]
12
- Msg.draw name
13
- return "Wish you a happy birthday!"
13
+ name = ".:" + name + s[-1] + ":."
14
+ msg = Message.new name
15
+ puts ""
16
+ msg.draw
17
+ puts ""
18
+ return "Wish you a happy birthday! <3"
14
19
  end
15
20
  end
@@ -0,0 +1,30 @@
1
+ class Message
2
+ def initialize name
3
+ @width = name.length < 31 ? 33 : name.length + 9 - name.length%4
4
+ @height = 9
5
+ @name = name
6
+ end
7
+
8
+ def insert txt, str
9
+ beg = (@width - txt.length)/2
10
+ fin = beg + txt.length - 1
11
+ str[beg..fin] = txt
12
+ end
13
+
14
+ def draw
15
+ msg = %w()
16
+ msg[0] = msg[@height-1] = "x . " * (@width/4) + "x"
17
+ for i in 1 .. @height-2 do
18
+ msg[i] = i%2 == 1 ? ("." + " " * (@width - 2) + ".") :
19
+ ("x" + " " * (@width - 2) + "x")
20
+ end
21
+
22
+ insert ">>> HAPPY BIRTHDAY! <<<", msg[2]
23
+ insert @name, msg[4]
24
+ insert "\\(*^ 3 ^*)/", msg[6]
25
+
26
+ for i in 0 .. msg.size-1
27
+ puts msg[i]
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module A1447llHpbd
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a1447ll_hpbd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Le Bao Linh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ files:
52
52
  - Rakefile
53
53
  - a1447ll_hpbd.gemspec
54
54
  - lib/a1447ll_hpbd.rb
55
- - lib/a1447ll_hpbd/msg.rb
55
+ - lib/a1447ll_hpbd/message.rb
56
56
  - lib/a1447ll_hpbd/version.rb
57
57
  homepage: ''
58
58
  licenses:
@@ -1,18 +0,0 @@
1
- class Msg
2
- def self.draw n
3
- border = "*.:." * 9 + "*"
4
- name = "|" + (' ' * ((35 - n.length)/2)) + n + (' ' * ((35 - n.length)/2)) + "|"
5
- b1 = '|' + (' ' * 35) + '|'
6
- b2 = '*' + (' ' * 35) + '*'
7
-
8
- puts border
9
- puts b1
10
- puts b2
11
- puts '|' + (' ' * 7) + ">> HAPPY BIRTHDAY! <<" + (' ' * 7) + '|'
12
- puts b2
13
- puts name
14
- puts b2
15
- puts b1
16
- puts border
17
- end
18
- end