Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
sleeping_king_studios-ext
Advanced tools
A collection of extensions to core classes.
YARD documentation is available at RubyDoc.info.
require 'sleeping_king_studios/ext/array/fold'
Loops through the items in the array and counts the number of times each item appears. If a block is provided, each item is passed into the block, and the result of yielding the block is counted instead.
Example: Find the number of times each item appears in the array.
items = %w(foo foo foo bar bar baz wibble wobble)
items.fold
#=> { 'foo' => 3, 'bar' => 2, 'baz' => 1, 'wibble' => 1, 'wobble' => 1 }
Example: Count the items in the array with each status value.
class SampleItem < Struct.new(:status); end
items = [
SampleItem.new :approved,
SampleItem.new :rejected,
SampleItem.new :approved,
SampleItem.new :approved,
SampleItem.new :error,
SampleItem.new nil,
SampleItem.new :rejected,
] # end array
items.fold { |item| item.status }
#=> { :approved => 3, :rejected => 2, :error => 1, nil => 1 }
require 'sleeping_king_studios/ext/integer/digits'
Breaks the number into its component digits in the specified base.
Example: Get the digits of a number in base 10.
23154.digits
#=> ['2', '3', '1', '5', '4']
Example: Get the digits of a number in base 2.
80.digits(2)
#=> ['1', '0', '1', '0', '0', '0', '0']
Example: Get digits of a number in base 16.
3894.digits(16)
#=> ['f', '3', '6']
require 'sleeping_king_studios/ext/integer/romanize'
Returns the value as a string of Roman numerals, i.e. the number 7 becomes the string "VII". The number must be greater than 0 and less than 5000.
Example: Get the number's representation in Roman numerals.
7.romanize
#=> 'VII'
18.romanize
#=> 'XVIII'
49.romanize
#=> 'XLIX'
3894.romanize
#=> 'MMMDCCCXCIV'
If the additive flag is set to true, uses the form 'IIII' for 4 and 'VIIII' for 9, as well instead of 'IV' and 'IX', respectively. Also applies to the tens and hundreds places, e.g. 40, 90, 400, and 900.
Example: Get the number's representation in additive Roman numerals.
499.romanize :additive => true
#=> 'CCCCLXXXXVIIII'
require 'sleeping_king_studios/ext/object/metaclass'
Returns the object's metaclass, a Class that holds any functionality specific
to that object instance, e.g. a method defined using
Object#define_singleton_method
, or a module that the instance extends.
SleepingKingStudios::Ext is released under the MIT License.
FAQs
Unknown package
We found that sleeping_king_studios-ext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.