rubyhelper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/rubyhelper/arrayhelper.rb +34 -0
- data/lib/rubyhelper/integerhelper.rb +10 -0
- data/lib/rubyhelper/stringhelper.rb +31 -0
- data/lib/rubyhelper/timehelper.rb +109 -0
- data/lib/rubyhelper.rb +6 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4daf657fead8d4e43150a8cb3e3acf4f4fa6be82
|
4
|
+
data.tar.gz: 31b8dcdd9fd9cfded7f07078a96ea031b6d851a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46c142d49f05fadedd84921cf53c61a986f882e3765ce04f43e1f043cbe73b88a68fa19494e5889cf903ae93c4ba82bd88f3a518b7155eb2f6c0392a195b5b31
|
7
|
+
data.tar.gz: f53ecc89cc325f8f8b221c4fbefec0a83db6652bb5ad70522e762bb981f7453dd5c878b9cbc27222a11f0cb06e9672bcd6186c855f97683a8400894bb7dfccc0
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
3
|
+
class Array
|
4
|
+
|
5
|
+
# A simple function like to_s(), but return a clean String
|
6
|
+
# for exemple :
|
7
|
+
# [1,2,3].to_clean_s(" ; ")
|
8
|
+
# => "1 ; 2 ; 3"
|
9
|
+
# ==Parameters:
|
10
|
+
# sep:
|
11
|
+
# A String to separe each element (or an Array, see to_clean_s_with_array)
|
12
|
+
def to_clean_s(sep=' ')
|
13
|
+
return to_clean_s_with_array(sep) if sep.is_a?Array
|
14
|
+
to_clean_s_with_string(sep.to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def to_clean_s_with_string sep
|
19
|
+
str = String.new
|
20
|
+
self.each{|e| str = str + e.to_s + sep.to_s}
|
21
|
+
return str[0..(-sep.size - 1)]
|
22
|
+
end
|
23
|
+
|
24
|
+
# You can use an array as separator : [",", " "] will successively ',' and ' '
|
25
|
+
def to_clean_s_with_array sep
|
26
|
+
str = String.new
|
27
|
+
i = 0
|
28
|
+
self.each do |e|
|
29
|
+
str = str + e.to_s + sep[i % sep.size].to_s
|
30
|
+
i += 1
|
31
|
+
end
|
32
|
+
return str[0..(-sep.size - 1)]
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
3
|
+
#CRYXOR DEPENDENCY
|
4
|
+
require 'digest'
|
5
|
+
|
6
|
+
class String
|
7
|
+
|
8
|
+
#CRYXOR
|
9
|
+
def ^(k)
|
10
|
+
str = ""
|
11
|
+
self.size.times do |i|
|
12
|
+
str << (self[i].ord ^ k[i % k.size].ord).chr
|
13
|
+
end
|
14
|
+
return str
|
15
|
+
end
|
16
|
+
|
17
|
+
#SHA2
|
18
|
+
def sha2
|
19
|
+
Digest::SHA2.hexdigest(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
#STATIC
|
23
|
+
def static(n, char=' ')
|
24
|
+
if self.size < n
|
25
|
+
return self + char * (n - self.size).to_i
|
26
|
+
else
|
27
|
+
return self[0...n]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#encoding: utf-8
|
3
|
+
|
4
|
+
class Time
|
5
|
+
|
6
|
+
def to_simple_date(sep='/')
|
7
|
+
sep = sep.to_s.tr_s('%', '')
|
8
|
+
self.strftime('%d' + sep + '%m' + sep + '%Y')
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_simple_time
|
12
|
+
self.strftime('%R')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# Date (Year, Month, Day):
|
18
|
+
# %Y - Year with century (can be negative, 4 digits at least)
|
19
|
+
# -0001, 0000, 1995, 2009, 14292, etc.
|
20
|
+
# %C - year / 100 (rounded down such as 20 in 2009)
|
21
|
+
# %y - year % 100 (00..99)
|
22
|
+
|
23
|
+
# %m - Month of the year, zero-padded (01..12)
|
24
|
+
# %_m blank-padded ( 1..12)
|
25
|
+
# %-m no-padded (1..12)
|
26
|
+
# %B - The full month name (``January'')
|
27
|
+
# %^B uppercased (``JANUARY'')
|
28
|
+
# %b - The abbreviated month name (``Jan'')
|
29
|
+
# %^b uppercased (``JAN'')
|
30
|
+
# %h - Equivalent to %b
|
31
|
+
|
32
|
+
# %d - Day of the month, zero-padded (01..31)
|
33
|
+
# %-d no-padded (1..31)
|
34
|
+
# %e - Day of the month, blank-padded ( 1..31)
|
35
|
+
|
36
|
+
# %j - Day of the year (001..366)
|
37
|
+
|
38
|
+
# Time (Hour, Minute, Second, Subsecond):
|
39
|
+
# %H - Hour of the day, 24-hour clock, zero-padded (00..23)
|
40
|
+
# %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
|
41
|
+
# %I - Hour of the day, 12-hour clock, zero-padded (01..12)
|
42
|
+
# %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
|
43
|
+
# %P - Meridian indicator, lowercase (``am'' or ``pm'')
|
44
|
+
# %p - Meridian indicator, uppercase (``AM'' or ``PM'')
|
45
|
+
|
46
|
+
# %M - Minute of the hour (00..59)
|
47
|
+
|
48
|
+
# %S - Second of the minute (00..60)
|
49
|
+
|
50
|
+
# %L - Millisecond of the second (000..999)
|
51
|
+
# The digits under millisecond are truncated to not produce 1000.
|
52
|
+
# %N - Fractional seconds digits, default is 9 digits (nanosecond)
|
53
|
+
# %3N millisecond (3 digits)
|
54
|
+
# %6N microsecond (6 digits)
|
55
|
+
# %9N nanosecond (9 digits)
|
56
|
+
# %12N picosecond (12 digits)
|
57
|
+
# %15N femtosecond (15 digits)
|
58
|
+
# %18N attosecond (18 digits)
|
59
|
+
# %21N zeptosecond (21 digits)
|
60
|
+
# %24N yoctosecond (24 digits)
|
61
|
+
# The digits under the specified length are truncated to avoid
|
62
|
+
# carry up.
|
63
|
+
|
64
|
+
# Time zone:
|
65
|
+
# %z - Time zone as hour and minute offset from UTC (e.g. +0900)
|
66
|
+
# %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
|
67
|
+
# %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
|
68
|
+
# %Z - Abbreviated time zone name or similar information.
|
69
|
+
|
70
|
+
# Weekday:
|
71
|
+
# %A - The full weekday name (``Sunday'')
|
72
|
+
# %^A uppercased (``SUNDAY'')
|
73
|
+
# %a - The abbreviated name (``Sun'')
|
74
|
+
# %^a uppercased (``SUN'')
|
75
|
+
# %u - Day of the week (Monday is 1, 1..7)
|
76
|
+
# %w - Day of the week (Sunday is 0, 0..6)
|
77
|
+
|
78
|
+
# ISO 8601 week-based year and week number:
|
79
|
+
# The first week of YYYY starts with a Monday and includes YYYY-01-04.
|
80
|
+
# The days in the year before the first week are in the last week of
|
81
|
+
# the previous year.
|
82
|
+
# %G - The week-based year
|
83
|
+
# %g - The last 2 digits of the week-based year (00..99)
|
84
|
+
# %V - Week number of the week-based year (01..53)
|
85
|
+
|
86
|
+
# Week number:
|
87
|
+
# The first week of YYYY that starts with a Sunday or Monday (according to %U
|
88
|
+
# or %W). The days in the year before the first week are in week 0.
|
89
|
+
# %U - Week number of the year. The week starts with Sunday. (00..53)
|
90
|
+
# %W - Week number of the year. The week starts with Monday. (00..53)
|
91
|
+
|
92
|
+
# Seconds since the Epoch:
|
93
|
+
# %s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
94
|
+
|
95
|
+
# Literal string:
|
96
|
+
# %n - Newline character (\n)
|
97
|
+
# %t - Tab character (\t)
|
98
|
+
# %% - Literal ``%'' character
|
99
|
+
|
100
|
+
# Combination:
|
101
|
+
# %c - date and time (%a %b %e %T %Y)
|
102
|
+
# %D - Date (%m/%d/%y)
|
103
|
+
# %F - The ISO 8601 date format (%Y-%m-%d)
|
104
|
+
# %v - VMS date (%e-%^b-%4Y)
|
105
|
+
# %x - Same as %D
|
106
|
+
# %X - Same as %T
|
107
|
+
# %r - 12-hour time (%I:%M:%S %p)
|
108
|
+
# %R - 24-hour time (%H:%M)
|
109
|
+
# %T - 24-hour time (%H:%M:%S)
|
data/lib/rubyhelper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyhelper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- poulet_a
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A list of utils for the basic Class of ruby.
|
14
|
+
email:
|
15
|
+
- poulet_a@epitech.eu
|
16
|
+
- - lib/rubyhelper.rb
|
17
|
+
- lib/rubyhelper/integerhelper.rb
|
18
|
+
- lib/rubyhelper/stringhelper.rb
|
19
|
+
- lib/rubyhelper/arrayhelper.rb
|
20
|
+
- lib/rubyhelper/timehelper.rb
|
21
|
+
executables: []
|
22
|
+
extensions: []
|
23
|
+
extra_rdoc_files: []
|
24
|
+
files:
|
25
|
+
- lib/rubyhelper.rb
|
26
|
+
- lib/rubyhelper/arrayhelper.rb
|
27
|
+
- lib/rubyhelper/integerhelper.rb
|
28
|
+
- lib/rubyhelper/stringhelper.rb
|
29
|
+
- lib/rubyhelper/timehelper.rb
|
30
|
+
homepage: https://gitlab.com/Sopheny/rubyhelper
|
31
|
+
licenses:
|
32
|
+
- GNU/GPLv3
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 2.2.2
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Init
|
54
|
+
test_files: []
|
55
|
+
has_rdoc:
|