2 golfed more with smarter logic (-4 chars)
source | link

Ruby, 6254

A

$><<1if$<.read==openread==IO.read(?B).read

B

$><<1if not$<$><<1if$<.read==openread!=IO.read(?A).read

examples:

bash-3.2$ ruby A < A
bash-3.2$ ruby A < B
1bash-3.2$ ruby B < A
bash-3.2$ ruby B < B
1bash-3.2$ 

Ruby, 62

A

$><<1if$<.read==open(?B).read

B

$><<1if not$<.read==open(?A).read

examples:

bash-3.2$ ruby A < A
bash-3.2$ ruby A < B
1bash-3.2$ ruby B < A
bash-3.2$ ruby B < B
1bash-3.2$ 

Ruby, 54

A

$><<1if$<.read==IO.read(?B)

B

$><<1if$<.read!=IO.read(?A)

examples:

bash-3.2$ ruby A < A
bash-3.2$ ruby A < B
1bash-3.2$ ruby B < A
bash-3.2$ ruby B < B
1bash-3.2$ 
1
source | link

Ruby, 62

A

$><<1if$<.read==open(?B).read

B

$><<1if not$<.read==open(?A).read

examples:

bash-3.2$ ruby A < A
bash-3.2$ ruby A < B
1bash-3.2$ ruby B < A
bash-3.2$ ruby B < B
1bash-3.2$