'분류 전체보기'에 해당되는 글 256건

  1. 2007.07.18 xml 구문 객체로 바로 읽어들이기 1
  2. 2007.05.17 [JSON] json으로 개발하려면 필요한것들. 1
  3. 2007.04.03 이클립스 에서 한글이 깨질때
  4. 2007.03.27 특수문자표 일람
  5. 2007.03.19 [sampe] addBatch Query일괄실행
  6. 2007.02.22 [mysql] mysql backup 방법 2
  7. 2007.02.20 rsync 설정하기
  8. 2007.02.20 개발자 입장에서의 연휴.. 1
  9. 2007.02.15 [Ruby syntax] Ruby 문법 3
  10. 2007.02.15 내가관리하는 Project 일정관리 방법

  SAXReader reader = new SAXReader();
  Document document = reader.read(in);
  return parseData2Data(document);


참 간단한 구문이 아닐 수 없다.
하지만 가만히 보면 모든 xml 파싱에 비밀이 들어가 있다.
in 은 InputStream으로 URL상에 존재하는 내용을 InputStream으로 받아온다.
그 받아온 IN 객체를 SAXReader를 이용해서 바로 Document화 시킨다.

XML을 이용한 파싱할때 유용하게 사용될것 같다.

우선 자신의 JDK에 맞는 JSON LIB가 필요하다.
http://json-lib.sourceforge.net/ 여기에서 받아보자 (jdk 1.3용과 jdk 1.5가 있다.)


json이 여기서 받아야 하는 파일이 끝이라고 생각한다면 오산이다.

오류발생 : java.lang.NoClassDefFoundError: net/sf/ezmorph/MorpherRegistry

이것은 EZmorph가 없어서 발생하는 오류이다.
바로 연관 package가 추가로 더 있는 경우에 해당한다.

http://ezmorph.sourceforge.net/ 에서 추가로 다운받자.


최종!!
 > json-lib-1.1-jdk15-javadoc.jar / ezmorph-1.0.2.jar  2개가 있어야 구동이 가능함.


● 간단 sample 소스코드

 public oid test11DataTest () {
  JSONObject jsonObject = new JSONObject() ;
  jsonObject.put ("subject", "001");
  jsonObject.put ("author", "002");
  jsonObject.put ("date", "003");

  System.out.println("neouser ^^ >>>" + jsonObject.toString());
 }





-Dfile.encoding=UTF-8

VM argument에 위에 옵션을 부여해줍니다.

특수문자표 일람

개발 TIP 2007. 3. 27. 20:22
아~ 잘 까먹습니다.

<  &lt;
 ?  &#131;
 >  &gt;
&   &amp;
 †  &#134;
 "  &quot;
ⓒ   &copy
 ‰  &#137;
 ®  &reg;
공백   &nbsp;
 ?  &#159;
 ™  &trade
!  &#033;
 ¡  &#161;
 §  &sect;
"  &#039;
 ¢  &#162;
 æ  &aelig;
*  &#042;
 ¤  &#164;
 ¿  &#191;
=  &#061;
 ¥  &yen;
 ×  &times;

Query 한꺼번에 실행하는것 입니다.


  PoolManager pool = PoolManager.getInstance();
  Connection conn = null;
  PreparedStatement pstmt = null;
   
  try {
   conn = (Connection) pool.getConnection();  
   
pstmt = conn.prepareStatement("delete from neouserTable where name = ?");
   
   for (int i=0; i < daumid.length; i++) {  
    pstmt.setString (1, name[i]);
    pstmt.addBatch();
   }

 
   int results[] = pstmt.executeBatch();  
   returnValue ="true";
   
  } catch (BatchUpdateException e) {
      int rsSuccessCnts[] = e.getUpdateCounts();     //오류  발생 이전의 SQL 문에서 insert된 행 갯수를 배열로 리턴한다.
      for( int i=0; i<rsSuccessCnts.length; i++ ) {
       _logger.debug( i + "번째 쿼리 성공, 해당 쿼리에서 insert된 행 갯수: " + rsSuccessCnts[i] );
      }
      returnValue ="false";     
  } finally { PoolManager.close( pstmt, conn);}


1. 우선 backup을 수행해도 되는지 확인을 해보도록 합니다.
    > 만일 DB가 InnoDB 방식이라면 아래와 같은 명령어가 통한답니다.
      mysql>show table status

    > 만일 InnoDB 가 아니라면...
      [neouser@neouserdb-1 data]$ du --max-depth=1


2. 검토해본 결과 별다른 무리가 없다면 mysql을 backup을 받습니다.
  저에 경우에는  backup후 개발 장비에 데이터를 모두 뿌려넣고 싶었기 때문에 dump를 뜨도록 했습니다.

  > BACKUP
   데이터베이스명 : neouserdb
   생성할 sql파일명 : neouserdb.sql
   shell>$ mysqldump -uroot -p neouserdb > neouserdb.sql

  > RESTORE
   데이터베이스명 : neouserdb2
   생성할 sql파일명 : neouserdb.sql
     ※ 선행작업으로 데이터베이스는 만들어 놓으셔야 합니다.
   shell>$ mysql -uroot -p neouserdb2 < neouserdb.sql


3. 추가!!
 뭐든 뭔가 또다른 방법이 있기 마련이죠.
 mysql> load data local infile 'data.txt' into table table_name;
 shell>$
mysql -e "source /path-to-backup/backup-file.sql" db_name

이런것도 역시 찾으려 들면 검색엔진들은 뭐이리 쓰레기 데이터만 토해내는지..



rsync 설정하기

linux 2007. 2. 20. 22:56
고정업무에서 개발말고 간혹 linux작업이 요구될때가 있다.
영영 떠오를것 같지 않는 몇가지 설정 작업들중에 rsync 역시 이에 한목을 한다.
민첩한 개발자 분들은 이미 작업을 해 두셨겠지만 적어도 나같이 잘 못 외우는 분들이 있을꺼라
생각 되기에 설정방법을 기록해 본다.


1) vi /etc/xinetd.d/rsync 파일 수정
사용자 삽입 이미지

파일의  수정에서 가장 중요한 부분은 disable = yes 를 no 로 바꾸는것 이다.
사용자 삽입 이미지

2 )파일을 변경한 이후에는 꼭! xinitd를 restart 한다
사용자 삽입 이미지

3) vi /etc/services 파일 수정
사용자 삽입 이미지
본 파일에서는 특별히 수정보다는 rsync 포트가 설정되어있는것을 보안상 바꿀 필요가 있을경우 변경한다.
사용자 삽입 이미지

4) vi /etc/rsyncd.conf 파일 수정
  이 파일을 수정하게 되면 연결당시 host Domain 이후에 입력하는 구문을 줄여서 사용할 수 있다.
사용자 삽입 이미지
사용자 삽입 이미지

이상의 설정으로 우선 처리해야 하는 과정을 모두 거친것 같다.
이후에 연결을 시도했을때 발생하는 오류는 아래와 같다.
  > /etc/hosts.allow에 접속하려는 장비의 IP가 기록이 되지 않은 경우
  > /etc/hosts 에 설정에 맞는 ip가 등록이 안된경우

5) 모든 작업이 완료가 되었으면 test 해보도록 한다.
사용자 삽입 이미지
그림같이 별다른 메세지가 떨어지지 않는다면 성공이다. ^^


혹시  windows에서 linux로 rsync를 시도한다면 첨부된 파일을 가지고
 windows에 설치한뒤 path에 등록을 해주고 사용하도록 한다.
  설마~~ path 설정을 모르는건 아니겠죠?? (제어판 > 시스템 > 환경설정 )

쉽은 누구나에게 좋은 영향을 가져다 준다.
일에대한 새로운 자극이 되고 일을 새롭게 조명해 볼 수 있다는 점에서 장점을 가지고 있다.

하지만 개발자들에게는 평상시 대해왔던 소스코드와 키보드 자판을 멀리하게 되기에
연휴를 보내고 난 다음의 키보드 앞의 자신감이 연휴이전보다 사실 덜하다.
휴..

고향에 다녀온 즐거운 기분은 아직 사그러지지 않는 불씨가 되어
영혼속에 연휴가 가져다준 쉼은 여운이되는 일터에서의 첫날!!
민첩하게 키보드위를 단축키와 Function키를 누르며
이 코드 저 코드 해집어 가며 마치 어제 봤던 소스코드마냥 잘 다룰줄 알았는데
만만하게 볼 일이 아니게 되어버린다.
들리는 잡담들은 "나 말고도 다른 사람들도 비슷한 어려움을 겪나 보구나" 라는 동질감을 느끼고..
었차~~ "오늘 하루는 그냥 컴퓨터랑 다시 친해지기지 뭐.. " 하며 합리화 시키고
다음일을 위해 뭔가 또 생각을 한다.

다들 그런걸까? 아님 나만 그런걸까?
여하튼 연휴 후에 컴퓨터 앞의 내모습은 초보운전자의 모습되어
키보드 하나 누르는것에서도 약간의 어리숙함을 드러내고 만다.

휴식전에 내머리속에는 객체와, 다이어그램, 그리고 로직들이 떠돌아 다녔는데
휴식을 취하면서 그간 소홀이 했던 사람, 인간관계, 입에 서 나오는 말들의 꾸밈에 신경쓰다보니
다시금 코드들이 내머리속에서 잠시 소외되었던것 같다.


으샤~~
잘 쉬었다.
또 열심히 달려야지..
음.. 이번주는 내가 ATOM을 추가하기로 한 주간이다. (다이어리에 까먹을까봐 적어둔 쌘스^^)
나 말고 다른 개발자들도 연휴 후 컴퓨터와 친해지기가 잘 되었길 바란다.
아참! 그래도 개발자도 사람이니 연휴는 꼭! 필요하다는것!
잊지 말기 바랍니다 ^^



영문이라고 너무 서운해 하지 마세요 ^^
의미전달은 영문이 다소 편하답니다.
더욱시 sample 코드들이 들어 있어서 영문밖에 없다 불편해 하실것도
아닐것 같습니다.


Ruby syntax


The character set used in the Ruby source files for the current implementation is based on ASCII. The case of characters in source files is significant. All syntactic constructs except identifiers and certain literals may be separated by an arbitrary number of whitespace characters and comments. The whitespace characters are space, tab, vertical tab, backspace, carriage return, and form feed. Newlines works as whitespace only when expressions obviously continues to the next line.

Examples:

	foobar
	ruby_is_simple

Ruby identifiers are consist of alphabets, decimal digits, and the underscore character, and begin with a alphabets(including underscore). There are no restrictions on the lengths of Ruby identifiers.

Examples:

	# this is a comment line

Ruby comments start with "#" outside of a string or character literal (?#) and all following text until the end of the line.

Example:

	=begin
	the everything between a line beginning with `=begin' and
	that with `=end' will be skipped by the interpreter.
	=end

If the Ruby interpreter encounters a line beginning with =begin, it skips that line and all remaining lines through and including a line that begins with =end.

The reserved words are:

	BEGIN	 class	  ensure   nil	    self     when
	END	 def	  false    not	    super    while
	alias	 defined  for	   or	    then     yield
	and	 do	  if	   redo     true
	begin	 else	  in	   rescue   undef
	break	 elsif	  module   retry    unless
	case	 end	  next	   return   until

Example:

	print "hello world!\n"

Ruby programs are sequence of expressions. Each expression are delimited by semicolons(;) or newlines. Backslashes at the end of line does not terminate expression.

Examples:

	true
	(1+2)*3
	foo()
	if test then ok else ng end

Ruby expressions can be grouped by parentheses.

Examples:

	"this is a string expression\n"
	"concat#{foobar}"
	'concat#{foobar}'
	%q!I said, "You said, 'She said it.'"!
	%!I said, "You said, 'She said it.'"!
	%Q('This is it.'\n)

String expressions begin and end with double or single quote marks. Double-quoted string expressions are subject to backslash escape and expression substitution. Single-quoted strings are not (except for \' and \\).

The string expressions begin with % are the special form to avoid putting too many backslashes into quoted strings. The %q/STRING/ expression is the generalized single quote. The %Q/STRING/ (or %/STRING/) expression is the generalized double quote. Any non-alphanumeric delimiter can be used in place of /, including newline. If the delimiter is an opening bracket or parenthesis, the final delimiter will be the corresponding closing bracket or parenthesis. (Embedded occurrences of the closing bracket need to be backslashed as usual.)

Backslash notation   (top▲)

\t
tab(0x09)
\n
newline(0x0a)
\r
carriage return(0x0d)
\f
form feed(0x0c)
\b
backspace(0x08)
\a
bell(0x07)
\e
escape(0x1b)
\s
whitespace(0x20)
\nnn
character in octal value nnn
\xnn
character in hexadecimal value nn
\cx
control x
\C-x
control x
\M-x
meta x (c | 0x80)
\M-\C-x
meta control x
\x
character x itself

The string literal expression yields new string object each time it evaluated.

Examples:

	`date`
	%x{ date }

Strings delimited by backquotes are performed by a subshell after escape sequences interpretation and expression substitution. The standard output from the commands are taken as the value. Commands performed each time they evaluated.

The %x/STRING/ is the another form of the command output expression.

Examples:

	/^Ruby the OOPL/
	/Ruby/i
	/my name is #{myname}/o
	%r|^/usr/local/.*|

Strings delimited by slashes are regular expressions. The characters right after latter slash denotes the option to the regular expression. Option i means that regular expression is case insensitive. Option i means that regular expression does expression substitution only once at the first time it evaluated. Option x means extended regular expression, which means whitespaces and commens are allowd in the expression. Option p denotes POSIX mode, in which newlines are treated as normal character (matches with dots).

The %r/STRING/ is the another form of the regular expression.

^
beginning of a line or string
$
end of a line or string
.
any character except newline
\w
word character[0-9A-Za-z_]
\W
non-word character
\s
whitespace character[ \t\n\r\f]
\S
non-whitespace character
\d
digit, same as[0-9]
\D
non-digit
\A
beginning of a string
\Z
end of a string, or before newline at the end
\z
end of a string
\b
word boundary(outside[]only)
\B
non-word boundary
\b
backspace(0x08)(inside[]only)
[ ]
any single character of set
*
0 or more previous regular expression
*?
0 or more previous regular expression(non greedy)
+
1 or more previous regular expression
+?
1 or more previous regular expression(non greedy)
{m,n}
at least m but most n previous regular expression
{m,n}?
at least m but most n previous regular expression(non greedy)
?
0 or 1 previous regular expression
|
alternation
( )
grouping regular expressions
(?# )
comment
(?: )
grouping without backreferences
(?= )
zero-width positive look-ahead assertion
(?! )
zero-width negative look-ahead assertion
(?ix-ix)
turns on (or off) `i' and `x' options within regular expression. These modifiers are localized inside an enclosing group (if any).
(?ix-ix: )
turns on (or off) `i' and `x' options within this non-capturing group.

Backslash notation and expression substitution available in regular expressions.

Examples:

	"my name is #{$ruby}"

In double-quoted strings, regular expressions, and command output expressions, the form like "#{expression}" extended to the evaluated result of that expression. If the expressions are the variables which names begin with the character either `$',`@', expressions are not needed to be surrounded by braces. The character `#' is interpreted literally if it it not followed by characters `{',`$',`@'.

There's a line-oriente form of the string literals that is usually called as `here document'. Following a << you can specify a string or an identifier to terminate the string literal, and all lines following the current line up to the terminator are the value of the string. If the terminator is quoted, the type of quotes determines the type of the line-oriented string literal. Notice there must be no space between << and the terminator.

If the - placed before the delimiter, then all leading whitespcae characters (tabs or spaces) are stripped from input lines and the line containing delimiter. This allows here-documents within scripts to be indented in a natural fashion.

	  print <<EOF
	The price is #{$Price}.
	EOF

	  print <<"EOF";			# same as above
	The price is #{$Price}.
	EOF

	  print <<`EOC`			# execute commands
	echo hi there
	echo lo there
	EOC

	  print <<"foo", <<"bar"	# you can stack them
	I said foo.
	foo
	I said bar.
	bar

	  myfunc(<<"THIS", 23, <<'THAT')
	Here's a line
	or two.
	THIS
	and here's another.
	THAT

	  if need_define_foo
	    eval <<-EOS			# delimiters can be indented
              def foo
                print "foo\n"
	      end
	    EOS
          end

123
integer
-123
integer(signed)
1_234
integer(underscore within decimal numbers ignored)
123.45
floating point number
1.2e-3
floating point number
0xffff
hexadecimal integer
0b01011
binary integer
0377
octal integer
?a
ASCII code for character `a'(97)
?\C-a
Control-a(1)
?\M-a
Meta-a(225)
?\M-\C-a
Meta-Control-a(129)
:symbol
Integer corresponding identifiers, variable names, and operators.

In ?-representation all backslash notations are available.

The variable in Ruby programs can be distinguished by the first character of its name. They are either global variables, instance variables, local variables, and class constants. There are no restriction for variable name length (except heap size).

Examples:

	$foobar
	$/

The variable which name begins with the character `$', has global scope, and can be accessed from any location of the program. Global variables are available as long as the program lives. Non-initialized global variables has value nil.

Examples:

	@foobar

The variable which name begins which the character `@', is an instance variable of self. Instance variables are belong to the certain object. Non-initialized instance variables has value nil.

Examples:

	FOOBAR

The identifier which name begins with upper case letters ([A-Z]) is an constant. The constant definitions are done by assignment in the class definition body. Assignment to the constants must be done once. Changing the constant value or accessing to the non-initialized constants raises a NameError exception.

The constants can be accessed from:

  • the class or module body in which the constant is defined, including the method body and the nested module/class definition body.
  • the class which inherit the constant defining class.
  • the class or module which includes the constant defining module.

Class definition defines the constant automatically, all class names are constants.

To access constants defined in certain class/module, operator :: can be used.

To access constants defined in the Object class, operator :: without the left hand side operand can be used.

Examples:

	Foo::Bar
	::Bar

No assignment using operator `::' is permitted.

Examples:

	foobar

The identifier which name begins with lower case character or underscore, is a local variable or a method invocation. The first assignment in the local scope (bodies of class, module, method definition) to such identifiers are declarations of the local variables. Non-declared identifiers are method invocation without arguments.

The local variables assigned first time in the blocks are only valid in that block. They are called `dynamic variables.' For example:

	i0 = 1
	loop {
	  i1 = 2
	  print defined?(i0), "\n"	# true
	  print defined?(i1), "\n"	# true
	  break
	}
	print defined?(i0), "\n"	# true
	print defined?(i1), "\n"	# false

There are special variables called `pseudo variables'.

self
the receiver of the current method
nil
the sole instance of the Class NilClass(represents false)
true
the sole instance of the Class TrueClass(typical true value)
false
the sole instance of the Class FalseClass(represents false)
__FILE__
the current source file name.
__LINE__
the current line number in the source file.

The values of the pseudo variables cannot be changed. Assignment to these variables causes exceptions.

Examples:

	[1, 2, 3]

Syntax:

	`[' expr,...`]'

Returns an array, which contains result of each expressions. Arrays are instances of the class Array.

%w expressions make creation of the arrays of strings easier. They are equivalent to the single quoted strings split by the whitespaces. For example:

	%w(foo bar baz)

is equivalent to ["foo", "bar", "baz"]. Note that parenthesis right after %s is the quote delimiter, not usual parenthesis.

Examples:

	{1=>2, 2=>4, 3=>6}

Syntax:

	{ expr => expr...}

Returns a new Hash object, which maps each key to corresponding value. Hashes are instances of the class Hash.

Examples:

	foo.bar()
	foo.bar
	bar()
	print "hello world\n"
	print

Syntax:

[expr `.'] identifier [`(' expr...[`*' [expr]],[`&' ] expr`)']
[expr `::'] identifier [`(' expr...[`*' [expr]],[`&' expr] `)']

Method invocation expression invokes the method of the receiver (right hand side expression of the dot) specified by the identifier. If no receiver specified, self is used as a receiver.

Identifier names are normal identifiers and identifier suffixed by character ? or !. As a convention, identifier? are used as predicate names, and identifier! are used for the more destructive (or more dangerous) methods than the method which have same name without !.

If the last argument expression preceded by *, the value of the expression expanded to arguments, that means

	foo(*[1,2,3])
equals
	foo(1,2,3)

If the last argument expression preceded by &, the value of the expression, which must be a Proc object, is set as the block for the calling method.

Some methods are private, and can be called from function form invocations (the forms that omits receiver).

Examples:

	super
	super(1,2,3)

Syntax:

	super
	super(expr,...)

the super invokes the method which the current method overrides. If no arguments given, arguments to the current method passed to the method.

Examples:

	foo = bar
	foo[0] = bar
	foo.bar = baz

Syntax:

	variable '=' expr
	constant '=' expr
	expr`['expr..`]' '=' expr
	expr`.'identifier '=' expr

Assignment expression are used to assign objects to the variables or such. Assignments sometimes work as declarations for local variables or class constants. The left hand side of the assignment expressions can be either:

  • variables
    	variables `=' expression
    

    If the left hand side is a variables, then assignment is directly performed.

  • array reference
    	expr1`[' expr2...`]' `=' exprN
    

    This from is evaluated to the invocation of the method named []=, with expr1 as the receiver, and values expr2 to exprN as arguments.

  • attribute reference
    	expr `.' identifier `=' expr
    

    This from is evaluated to the invocation of the method named identifier= with the right hand side expression as a argument.

self assignment   (top▲)

Examples:

	foo += 12

Syntax:

	expr op= expr     # left hand side must be assignable.

This form evaluated as expr = expr op expr. But right hand side expression evaluated once. op can be one of:

	+, -, *, /, %, **, &, |, ^, <<, >>, &&, ||

There may be no space between operators and =.

Multiple assignment   (top▲)

Examples:

	foo, bar, baz = 1, 2, 3
	foo, = list()
	foo, *rest = list2()

Syntax:

	expr `,' [expr `,'...] [`*' expr] = expr [, expr...][`*' [expr]]
	`*' expr = expr [, expr...][`*' expr]

Multiple assignment form performs multiple assignment from expressions or an array. Each left hand side expression must be assignable. If single right hand side expression given, the value of the expression converted into an array, then each element in array assigned one by one to the left hand side expressions. If number of elements in the array is greater than left hand sides, they are just ignored. If left hand sides are longer than the array, nil will be added to the locations.

Multiple assignment acts like this:

	foo, bar = [1, 2]	# foo = 1; bar = 2
	foo, bar = 1, 2		# foo = 1; bar = 2
	foo, bar = 1		# foo = 1; bar = nil

	foo, bar, baz = 1, 2	# foo = 1; bar = 2; baz = nil
	foo, bar = 1, 2, 3	# foo = 1; bar = 2
	foo,*bar = 1, 2, 3	# foo = 1; bar = [2, 3]

The value of the multiple assignment expressions are the array used to assign.

Examples:

	1+2*3/4

As a syntax sugar, several methods and control structures has operator form. Ruby has operators show below:

	high   ::
	       []
	       **
	       -(unary)  +(unary)  !  ~
	       *  /  %
	       +  -
	       <<  >>
	       &
	       |  ^
	       >  >=  <  <=
	       <=> ==  === !=  =~  !~
	       &&
	       ||
	       .. ...
	       =(+=, -=...)
	       not
	low    and or

Most of operators are just method invocation in special form. But some operators are not methods, but built in to the syntax:

	=, .., ..., !, not, &&, and, ||, or, !=, !~ 

In addition, assignment operators(+= etc.) are not user-definable.

Control structures in Ruby are expressions, and have some value. Ruby has the loop abstraction feature called iterators. Iterators are user-definable loop structure.

if   (top▲)

Examples:

	if age >= 12 then
	  print "adult fee\n"
	else
	  print "child fee\n"
	end
	gender = if foo.gender == "male" then "male" else "female" end

Syntax:

	if expr [then]
	  expr...
	[elsif expr [then]
	  expr...]...
	[else
	  expr...]
	end

if expressions are used for conditional execution. The values false and nil are false, and everything else are true. Notice Ruby uses elsif, not else if nor elif.

If conditional part of if is the regular expression literal, then it evaluated like:

	$_ =~ /re/

if modifier

Examples:

	print "debug\n" if $debug

Syntax:

	expr if expr

executes left hand side expression, if right hand side expression is true.

Examples:

	unless $baby
	  feed_meat
	else
	  feed_milk
	end

Syntax:

	unless expr [then]
	  expr...
	[else
	  expr...]
	end

unless expressions are used for reverse conditional execution. It is equivalent to:

	if !(cond)
	  ...
	else
	  ...
	end

unless modifier

Examples:

	print "stop\n" unless valid($passwd)

Syntax:

	expr unless expr

executes left hand side expression, if right hand side expression is false.

case   (top▲)

Examples:

	case $age
	when 0 .. 2
	  "baby"
	when 3 .. 6
	  "little child"
	when 7 .. 12
	  "child"
	when 12 .. 18
	  # Note: 12 already matched by "child"
	  "youth"
	else
	  "adult"
	end

Syntax:

	case expr
	[when expr [, expr]...[then]
	  expr..]..
	[else
	  expr..]
	end

the case expressions are also for conditional execution. Comparisons are done by operator ===. Thus:

	case expr0
	when expr1, expr2
	  stmt1
	when expr3, expr4
	  stmt2
	else
	  stmt3
	end

is basically same to below:

	_tmp = expr0
	if expr1 === _tmp || expr2 === _tmp
	  stmt1
	elsif expr3 === _tmp || expr4 === _tmp
	  stmt2
	else
	  stmt3
	end

Behavior of the === method varies for each Object. See docutmentation for each class.

and   (top▲)

Examples:

	test && set
	test and set

Syntax:

	expr `&&' expr
	expr `and' expr

Evaluates left hand side, then if the result is true, evaluates right hand side. and is lower precedence alias.

or   (top▲)

Examples:

	demo || die
	demo or die

Syntax:

	expr `||' expr
	expr or expr

Evaluates left hand side, then if the result is false, evaluates right hand side. or is lower precedence alias.

not   (top▲)

Examples:

	! me
	not me
	i != you

Syntax:

	`!' expr
	not expr

Returns true if false, false if true.

	expr `!=' expr

Syntax sugar for !(expr == expr).

	expr `!~' expr

Syntax sugar for !(expr =~ expr).

Examples:

	1 .. 20
	/first/ ... /second/

Syntax:

	expr `..' expr
	expr `...' expr

If range expression appears in any other place than conditional expression, it returns range object from left hand side to right hand side.

If range expression appears in conditional expression, it gives false until left hand side returns true, it stays true until right hand side is true. .. acts like awk, ... acts like sed.

while    (top▲)

Examples:

	while sunshine
	  work()
	end

Syntax:

	while expr [do]
	  ...
	end

Executes body while condition expression returns true.

while modifier

Examples:

	sleep while idle

Syntax:

	expr while expr

Repeats evaluation of left hand side expression, while right hand side is true. If left hand side is begin expression, while evaluates that expression at lease once.

Examples:

	until sunrise
	  sleep
	end

Syntax:

	until expr [do]
	  ...
	end

Executes body until condition expression returns true.

until modifier

Examples:

	work until tired

Syntax:

	expr until expr

Repeats evaluation of left hand side expression, until right hand side is true. If left hand side is begin expression, until evaluates that expression at lease once.

Examples:

	[1,2,3].each do |i| print i*2, "\n" end
	[1,2,3].each{|i| print i*2, "\n"}

Syntax:

	method_call do [`|' expr...`|'] expr...end
	method_call `{' [`|' expr...`|'] expr...`}'

The method may be invoked with the block (do .. end or {..}). The method may be evaluate back that block from inside of the invocation. The methods that calls back the blocks are sometimes called as iterators. The evaluation of the block from iterator is done by yield.

The difference between do and braces are:

  • Braces has stronger precedence. For example:
    	foobar a, b do .. end	# foobar will be called with the block.
    	foobar a, b { .. }	# b will be called with the block.
    
  • Braces introduce the nested local scopes, that is newly declared local variables in the braces are valid only in the blocks. For example:
    	foobar {
    	  i = 20		# local variable `i' declared in the block.
    	  ...
    	}
    	print defined? i	# `i' is not defined here.     
    	foobar a, b { .. }	# it is not valid outside of the block
    

for   (top▲)

Examples:

	for i in [1, 2, 3]
	  print i*2, "\n"
	end

Syntax:

	for lhs... in expr [do]
	  expr..
	end

Executes body for each element in the result of expression. for is the syntax sugar for:

	(expr).each `{' `|' lhs..`|' expr.. `}'

Examples:

	yield data

Syntax:

	yield `(' [expr [`,' expr...]])
	yield [expr [`,' expr...]]

Evaluates the block given to the current method with arguments, if no argument is given, nil is used as an argument. The argument assignment to the block prameter is done just like multiple assignment. If the block is not supplied for the current method, the exception is raised.

Examples:

	raise "you lose"  # raise RuntimeError
	# both raises SyntaxError
	raise SyntaxError, "invalid syntax"
	raise SyntaxError.new("invalid syntax")
	raise		  # re-raise last exception

Syntax:

	raise
	raise message_or_exception
	raise error_type, message
	raise error_type, message, traceback

Raises a exception. In the first form, re-raises last exception. In second form, if the argument is the string, creates a new RuntimeError exception, and raises it. If the argument is the exception, raise raises it. In the third form, raise creates a new exception of type error_type, and raises it. In the last form, the third argument is the traceback information for the raising exception in the format given by variable $@ or caller function.

The exception is assigned to the variable $!, and the position in the source file is assigned to the $@.

The word `raise' is not the reserved word in Ruby. raise is the method of the Kernel module. There is an alias named fail.

Examples:

	begin
	  do_something
	rescue
	  recover
	ensure
	  must_to_do
	end

Syntax:

	begin
	  expr..
	[rescue [error_type,..]
	  expr..]..
	[else
	  expr..]
	[ensure
	  expr..]
	end

begin expression executes its body and returns the value of the last evaluated expression.

If an exception occurs in the begin body, the rescue clause with the matching exception type is executed (if any). The match is done by the kind_of?. The default value of the rescue clause argument is the StandardError, which is the superclass of most built-in exceptions. Non-local jumps like SystemExit or Interrupt are not subclass of the StandardError.

The begin statement has an optional else clause, which must follow all rescue clauses. It is executed if the begin body does not raise any exception.

For the rescue clauses, the error_type is evaluated just like the arguments to the method call, and the clause matches if the value of the variable $! is the instance of any one of the error_type of its subclass. If error_type is not class nor module, the rescue clause raises TypeError exception.

If ensure clause given, its clause body executed whenever beginbody exits.

Examples:

	retry

Syntax:

	retry

If retry appears in rescue clause of begin expression, restart from the beginning of the 1begin body.

	begin
	  do_something # exception raised
	rescue
	  # handles error
	  retry  # restart from beginning
	end

If retry appears in the iterator, the block, or the body of the for expression, restarts the invocation of the iterator call. Arguments to the iterator is re-evaluated.

	for i in 1..5
	  retry if some_condition # restart from i == 1
	end
	# user defined "until loop"
	def UNTIL(cond)
	  yield
	  retry if not cond
	end

retry out of rescue clause or iterators raises exception.

Examples:

	return
	return 12
	return 1,2,3

Syntax:

	return [expr[`,' expr...]]

Exits from method with the return value. If more than two expressions are given, the array contains these values will be the return value. If no expression given, nil will be the return value.

Examples:

	i=0
	while i<3
	  print i, "\n"
	  break
	end

Syntax:

	break

Exits from the most internal loop. Notice break does not exit from case expression like C.

next    (top▲)

Examples:

	next

Syntax:

	next

Jumps to next iteration of the most internal loop.

redo   (top▲)

Examples:

	redo

Syntax:

	redo

Restarts this iteration of the most internal loop, without checking loop condition.

Examples:

	BEGIN {
	  ...
	}

Syntax:

	BEGIN '{'
	  expr..
	'}'

Registers the initialize routine. The block followed after BEGIN is evaluated before any other statement in that file (or string). If multiple BEGIN blocks are given, they are evaluated in the appearing order.

The BEGIN block introduce new local-variable scope. They don't share local variables with outer statements.

The BEGIN statement can only appear at the toplevel.

Examples:

	END {
	  ...
	}

Syntax:

	END '{' expr.. '}'

Registers finalize routine. The block followed after END is evaluated just before the interpreter termination. Unlike BEGIN, END blocks shares their local variables, just like blocks.

The END statement registers its block only once at the first execution. If you want to register finalize routines many times, use at_exit.

The END statement can only appear at the toplevel. Also you cannot cancel finalize routine registered by END.

Examples:

	class Foo < Super
	  def test
	     :
	  end
	     :
	end

Syntax:

	class identifier [`<' superclass ]
	  expr..
	end

Defines the new class. The class names are identifiers begin with uppercase character.

Examples:

	class << obj
	  def test
	     :
	  end
	     :
	end

Syntax:

	class `<<' expr
	  expr..
	end

Defines the class attribute for certain object. The definitions within this syntax only affect the specified object.

Examples:

	module Foo
	  def test
	     :
	  end
	     :
	end

Syntax:

	module identifier
	  expr..
	end

Defines the new module The module names are identifiers begin with uppercase character.

Examples:

	def fact(n)
	  if n == 1 then
	     1 
	  else
	    n * fact(n-1)
	  end
	end

Syntax:

	def method_name [`(' [arg ['=' default]]...[`,' `*' arg ]`)']
	  expr..
	end

Defines the new method. Method_name should be either identifier or re-definable operators (e.g. ==, +, -, etc.). Notice the method is not available before the definition. For example:

	foo
	def foo
	  print "foo\n"
	end
will raise an exception for undefined method invoking.

The argument with default expression is optional. The evaluation of the default expression is done at the method invocation time. If the last argument preceded by *, actual parameters which don't have corresponding formal arguments are assigned in this argument as an array.

If the last argument preceded by &, the block given to the method is converted into the Proc object, and assigned in this argument. In case both * and & are present in the argument list, & should come later.

The method definitions can not be nested.

The return value of the method is the value given to the return, or that of the last evaluated expression.

Some methods are marked as `private', and must be called in the function form.

When the method is defined outside of the class definition, the method is marked as private by default. On the other hand, the methods defined in the class definition are marked as public by default. The default visibility and the `private' mark of the methods can be changed by public or private of the Module.

In addition, the methods named initialize are always defined as private methods.

Examples:

	def foo.test
	  print "this is foo\n"
	end

Syntax:

	def expr `.' identifier [`(' [arg [`=' default]]...[`,' `*' arg ]`)']
	  expr..
	end

The singleton-method is the method which belongs to certain object. The singleton-method definitions can be nested.

The singleton-methods of classes inherited to its subclasses. The singleton-methods of classes are acts like class methods in other object-oriented languages.

Examples:

	alias foo bar
	alias $MATCH $&

Syntax:

	alias method-name method-name
	alias global-variable-name global-variable-name

Gives alias to methods or global variables. Aliases can not be defined within the method body.

The aliase of the method keep the current definition of the method, even when methods are overridden.

Making aliases for the numbered global variables ($1, $2,...) is prohibited. Overriding the builtin global variables may cause serious problems.

Examples:

	undef bar

Syntax:

	undef method-name

Cancels the method definition. Undef can not appear in the method body. By using undef and alias, the interface of the class can be modified independently from the superclass, but notice it may be broke programs by the internal method call to self.

Examples:

	defined? print
	defined? File.print
	defined?(foobar)
	defined?($foobar)
	defined?(@foobar)
	defined?(Foobar)

Syntax:

	defined? expr

Returns false if the expression is not defined. Returns the string that describes a kind of the expression.

matz@netlab.co.jp

Project 일정관리는 생각보다 매우 중요하다
나에게 일을 시킨사람 혹은 회사가 보이지 않는 S/W의 진행사항을 어떻게 확인 할 수 있는가?

재조업이라면 제품이 만들어지는 과정을 눈으로 보면 다행이겠지만
S/W말로 부드럽기 때문에 이런 공정을 보이지 못하는점이 참 아쉽다.

그래서 개인적으로 사용하는 일정관리방법을 소개 하려고 한다.
돈이 조금 있는 금융권 프로젝트라면 갑사나 주관사에서 msproject2000 정도의 라이센스를
가지고 있다.
음.. 이정도 툴을 가지고 한다면 프린트를 해도 예쁘고 일을 진행하는데도 별다른 어려움은 없다.

하/지/만..
작거나 개인적으로 하거나 했을경우 어떠한 방법이 가장 좋을까?
개인적으로 이런 일정관리를 위해 엑셀을 잘 이용한다. ^^

수식계산을 하는것 이라고 간과하지 말기 바란다.
엑셀이야 말로 msproject2000없는 프로젝트 일정 관리에서 PM혹은 PL이 먼저 챙겨야할
일정관리 툴 이니까 말이다.


사용자 삽입 이미지

아~ 보아라 이 얼마나 아름다우신가.
세상에 프로젝트들을 엑섹로 널리 이롭게 하라!! ^^

1 ··· 18 19 20 21 22 23 24 ··· 26 

글 보관함

카운터

Total : / Today : / Yesterday :
get rsstistory!