html-native 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7d9334c86a350e7f344e3c1ba7a959d2dbc2b480ae74f0690dc2e8df45c26d6
4
- data.tar.gz: 8697f7d54be0f9d86df14c6ccd97b3a52d73b48803a7dce76ce50ea9526549ef
3
+ metadata.gz: 21997059907e655e0171cd63d1b7bac5be51d1c3474c87849b508463a1ab011b
4
+ data.tar.gz: c87c0911546412b8954dd674f22ccd128f0b2ce985df085e2f38cbce3c150686
5
5
  SHA512:
6
- metadata.gz: 0bfa60e3c71b9e08e633be4a019922cc6761097e39a9be382f7cbabf2fc2a49ff44f2d4def80a68fd1e6619858ac7c72b08c48a5f6a0b63215bcc947c23ad510
7
- data.tar.gz: 2d5bfb8a037ca4e6aa243a375b81d503ffa2069f02c2fd1d3c5ae05a59b7b2f24eb8e602516a7e3f22b082367ade7d8e4423deb4fa17abd8a60a90c60b0a2f04
6
+ metadata.gz: 566d2c708f9c6829eb727f71f461d1499093ab995a35fdb5748f8b68dc157fb4bf6c650c02acc5cd6a6fc14c88224ea1c0921cbfded11244ebe6a7890ff4e3d7
7
+ data.tar.gz: ed6f3a80fea8a20e058770804255f87b93999dcf6d0b81cebaead9bbd2628750e2581549cbc536c16f8581b046e8f5fdfd0f6fc07fe86dc2165a10bf2a35cfdc
data/lib/html-native.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "html-native/constants"
2
2
  require "html-native/builder"
3
+ require "html-native/logic"
3
4
 
4
5
  module HTMLComponent
5
6
 
@@ -9,14 +9,14 @@ module HTMLComponent
9
9
  # the initial value.
10
10
  def initialize(strings = [])
11
11
  @strings = []
12
- @cache = case strings.class
13
- when Array
14
- strings.join
15
- when Enumerable
16
- strings.to_a.join
17
- else
18
- strings.to_s
19
- end
12
+ @cache =
13
+ if strings.kind_of? Array
14
+ strings.join
15
+ elsif strings.kind_of? Enumerable
16
+ strings.to_a.join
17
+ else
18
+ strings.to_s
19
+ end
20
20
  @cached = true
21
21
  end
22
22
 
@@ -0,0 +1,38 @@
1
+ module HTMLComponent
2
+ class Builder
3
+ define_method(:if) do |bool|
4
+ if bool
5
+ self
6
+ else
7
+ Builder.new
8
+ end
9
+ end
10
+
11
+ define_method(:unless) do |bool|
12
+ if bool
13
+ Builder.new
14
+ else
15
+ self
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ class String
22
+ define_method(:if) do |bool|
23
+ if bool
24
+ Builder.new(self)
25
+ else
26
+ Builder.new
27
+ end
28
+ end
29
+
30
+ define_method(:unless) do |bool|
31
+ # BAd form, purely for symmetry
32
+ unless bool
33
+ Builder.new(self)
34
+ else
35
+ Builder.new
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kellen Watt
@@ -20,6 +20,7 @@ files:
20
20
  - lib/html-native/builder.rb
21
21
  - lib/html-native/collections.rb
22
22
  - lib/html-native/constants.rb
23
+ - lib/html-native/logic.rb
23
24
  homepage: https://github.com/KellenWatt/html-native
24
25
  licenses:
25
26
  - MIT