Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Reale committed Nov 16, 2016
1 parent 27095ce commit 344d78d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
27 changes: 27 additions & 0 deletions lib/datatype/integer
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ function bashlets_datatype_integer_to_string()
env printf "%0${digits}d\n" "$n"
}

#@method
function bashlets_datatype_integer_select_bit()
{
########################################################################
#
# cf. https://github.com/ldante86/punch/blob/master/punch.sh
#
# Copyright (C) 2015 Luciano D. Cecere <ldante86@aol.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################

echo $(( $1 & (1<<$2) ))
}

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
Expand Down
27 changes: 0 additions & 27 deletions lib/datatype/number
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,6 @@ function bashlets_datatype_number_validate_as_unsigned_float()
[[ $1 =~ ^\+?[0-9]*\.?[0-9]+$ ]]
}

#@method
function bashlets_datatype_number_select_bit()
{
########################################################################
#
# cf. https://github.com/ldante86/punch/blob/master/punch.sh
#
# Copyright (C) 2015 Luciano D. Cecere <ldante86@aol.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################

echo $(( $1 & (1<<$2) ))
}

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
Expand Down
4 changes: 2 additions & 2 deletions plugins/datatype/string
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


source bashlet datatype/char
source bashlet datatype/number
source bashlet datatype/integer

#@method
function bashlets_datatype_string_punch()
Expand Down Expand Up @@ -122,7 +122,7 @@ function bashlets_datatype_string_punch()
for ((i=0; i<${#str}; i++))
do
p=$(char ascii2decimal ${str:i:1})
if [ $(number select_bit ${HOLES[p]} $((11 - row)) ) -ne 0 ]; then
if [ $(integer select_bit ${HOLES[p]} $((11 - row)) ) -ne 0 ]; then
echo -n "]"
else
echo -n "${ROWCHARS[row]}"
Expand Down

0 comments on commit 344d78d

Please sign in to comment.