Class: String
Instance Method Summary collapse
- #^(h = {}) ⇒ Object
- #arrayable ⇒ Object
- #bucket_exists? ⇒ Boolean
- #bucket_object(key) ⇒ Object
- #bucket_object_exists?(key) ⇒ Boolean
- #bucket_objects ⇒ Object
- #classify ⇒ Object
- #delete_bucket ⇒ Object
- #delete_bucket_value(key) ⇒ Object
- #hasherize(format = []) ⇒ Object
- #nice_runnable(quite = true) ⇒ Object
- #runnable(quite = true) ⇒ Object
- #store_bucket_value(key, data) ⇒ Object
Instance Method Details
#^(h = {}) ⇒ Object
14 15 16 |
# File 'lib/core/string.rb', line 14 def ^(h={}) self.gsub(/:([\w]+)/) {h[$1.to_sym] if h.include?($1.to_sym)} end |
#arrayable ⇒ Object
17 18 19 |
# File 'lib/core/string.rb', line 17 def arrayable self.strip.split(/\n/) end |
#bucket_exists? ⇒ Boolean
45 46 47 48 49 50 51 52 |
# File 'lib/core/string.rb', line 45 def bucket_exists? begin AWS::S3::Bucket.find(self) return true rescue return false end end |
#bucket_object(key) ⇒ Object
33 34 35 |
# File 'lib/core/string.rb', line 33 def bucket_object(key) AWS::S3::S3Object.value key, self if bucket_object_exists?(key) end |
#bucket_object_exists?(key) ⇒ Boolean
36 37 38 |
# File 'lib/core/string.rb', line 36 def bucket_object_exists?(key) AWS::S3::S3Object.exists? key, self end |
#bucket_objects ⇒ Object
30 31 32 |
# File 'lib/core/string.rb', line 30 def bucket_objects AWS::S3::Bucket.objects(self) end |
#classify ⇒ Object
27 28 29 |
# File 'lib/core/string.rb', line 27 def classify self.capitalize end |
#delete_bucket ⇒ Object
53 54 55 |
# File 'lib/core/string.rb', line 53 def delete_bucket AWS::S3::Bucket.delete(self, :force => true) if bucket_exists? end |
#delete_bucket_value(key) ⇒ Object
42 43 44 |
# File 'lib/core/string.rb', line 42 def delete_bucket_value(key) AWS::S3::S3Object.delete(key, self) if bucket_object_exists?(key) end |
#hasherize(format = []) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/core/string.rb', line 2 def hasherize(format=[]) hash = {} i = 0 self.split(%r{[\n|\t|\s| ]+}).collect {|a| a.strip}.each do |f| break unless format[i] unless f == "" || f.nil? hash[format[i]] = f i+=1 end end hash end |
#nice_runnable(quite = true) ⇒ Object
24 25 26 |
# File 'lib/core/string.rb', line 24 def nice_runnable(quite=true) self.split(/ && /).join("\n") end |
#runnable(quite = true) ⇒ Object
20 21 22 23 |
# File 'lib/core/string.rb', line 20 def runnable(quite=true) # map {|l| l << "#{" >/dev/null 2>/dev/null" if quite}" }. self.strip.split(/\n/).join(" && ") end |