Skip to content

Commit

Permalink
- Added the String.looks_like_number() method
Browse files Browse the repository at this point in the history
- Added the following Sys methods: refaddr, reftype, weaken, isweak, unweaken
  • Loading branch information
trizen committed Jul 8, 2015
1 parent 0322aab commit 33bf066
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/Sidef/Sys/Sys.pm
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,36 @@ package Sidef::Sys::Sys {
CORE::bless $obj, $class;
}

sub refaddr {
my ($self, $obj) = @_;
state $x = require Scalar::Util;
Sidef::Types::Number::Number->new(Scalar::Util::refaddr($obj));
}

sub reftype {
my ($self, $obj) = @_;
state $x = require Scalar::Util;
Sidef::Types::String::String->new(Scalar::Util::reftype($obj));
}

sub weaken {
my ($self, $obj) = @_;
state $x = require Scalar::Util;
Sidef::Types::Bool::Bool->new(Scalar::Util::weaken($obj));
}

sub isweak {
my ($self, $obj) = @_;
state $x = require Scalar::Util;
Sidef::Types::Bool::Bool->new(Scalar::Util::isweak($obj));
}

sub unweaken {
my ($self, $obj) = @_;
state $x = require Scalar::Util;
Sidef::Types::Bool::Bool->new(Scalar::Util::unweaken($obj));
}

sub copy {
my ($self, $obj) = @_;
state $x = require Storable;
Expand Down
40 changes: 40 additions & 0 deletions lib/Sidef/Sys/Sys.pod
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ Return the

=cut

=head2 isweak

Sys.isweak() -> I<Obj>

Return the

=cut

=head2 nanosleep

Sys.nanosleep() -> I<Obj>
Expand Down Expand Up @@ -354,6 +362,22 @@ Return the

=cut

=head2 refaddr

Sys.refaddr() -> I<Obj>

Return the

=cut

=head2 reftype

Sys.reftype() -> I<Obj>

Return the

=cut

=head2 run

Sys.run() -> I<Obj>
Expand Down Expand Up @@ -496,6 +520,14 @@ Return the

=cut

=head2 unweaken

Sys.unweaken() -> I<Obj>

Return the

=cut

=head2 user

Sys.user() -> I<Obj>
Expand All @@ -521,3 +553,11 @@ Sys.warn() -> I<Obj>
Return the

=cut

=head2 weaken

Sys.weaken() -> I<Obj>

Return the

=cut
6 changes: 6 additions & 0 deletions lib/Sidef/Types/String/String.pm
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,12 @@ package Sidef::Types::String::String {

*endsWith = \&ends_with;

sub looks_like_number {
my ($self) = @_;
state $x = require Scalar::Util;
Sidef::Types::Bool::Bool->new(Scalar::Util::looks_like_number($self->get_value));
}

sub warn {
my ($self) = @_;
warn $self->get_value;
Expand Down
8 changes: 8 additions & 0 deletions lib/Sidef/Types/String/String.pod
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ Return the

=cut

=head2 looks_like_number

String.looks_like_number() -> I<Obj>

Return the

=cut

=head2 new

String.new() -> I<Obj>
Expand Down

0 comments on commit 33bf066

Please sign in to comment.