get_indent 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/indent.rb +17 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cfa2df5b7a1cdb05ffa665500fb829108f598b3
4
- data.tar.gz: f3d6141abdcb672183ba8ec127d654eb053f94a2
3
+ metadata.gz: 34fcf20e588aa1579b84b39929a80b3c4f477534
4
+ data.tar.gz: e011371f30203c264c4e80f6578c472159d1ca27
5
5
  SHA512:
6
- metadata.gz: d64e5c50965ab2ec6e8fd3853b28108b0026e61606be3371e4c190822b402f0ec719a13e1b55aec621eb15b0d1326ba754ca3dce672f39a9eacab9194acf4f34
7
- data.tar.gz: e58e342abd7857b4d12c61918723eb7c8958e56c82894f138434a9035a1d3c22df64abcf8566676bfd9cc5538f4e859f95a19e489da5a957c6957e460560e9c7
6
+ metadata.gz: c02eaa6528975b5522c25f615ba0eb0f4b1bb973880bd468e4a668f3ffcb15d748b8da15ae301f0163faf4dd61bb3a5ea8f064ec7cc804ce53e38d33d1ffcea1
7
+ data.tar.gz: abd602c3aebaebf534c293926d9a9498f1b14d469bfb896c08c35e6a975925a7f75037907de4a718bd273ca84ba6dba23d139d455643bef3746255d41734155e
data/lib/indent.rb ADDED
@@ -0,0 +1,17 @@
1
+ def __get_indent n
2
+ caller = caller_locations(1,1)[n]
3
+ line = IO.readlines(caller.absolute_path)[caller.lineno-1]
4
+
5
+ cnt = 0
6
+ line.each_char do |c|
7
+ return cnt / 2 if c != ' '
8
+ cnt += 1
9
+ end
10
+ end
11
+
12
+ def __indent__
13
+ __get_indent 0
14
+ end
15
+ def __indent_of_caller__
16
+ __get_indent 1
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_indent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pjc0247
@@ -18,6 +18,7 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/get_indent.rb
21
+ - lib/indent.rb
21
22
  homepage: http://github.com/pjc0247/indent
22
23
  licenses: []
23
24
  metadata: {}